1 | #define MAX_NUMBER_OF_OPENED_TCP_SOCKETS 100
|
---|
2 |
|
---|
3 | /*
|
---|
4 | OpenSockets opens NumberOfSockets TCP Sockets.
|
---|
5 | a pointer to an array of SocketDescriptors is returned.
|
---|
6 | In case of error, the NULL pointer is returned.
|
---|
7 |
|
---|
8 | In order to Close the Sockets and free memory call
|
---|
9 | void CloseSockets(int * SocketDescriptors, unsigned int NumberOfSockets);
|
---|
10 | */
|
---|
11 | int * OpenSockets(unsigned int NumberOfSockets);
|
---|
12 |
|
---|
13 | /*
|
---|
14 | EmptySockets is used to read as much data from the TCP-Sockets in question
|
---|
15 | as possible. After waiting "timeout_usec" (default 125ms) -- see header file
|
---|
16 | without any data beeing present, the Socket is assumed to be empty.
|
---|
17 |
|
---|
18 | Hopefully it is.
|
---|
19 |
|
---|
20 | return is true if there was no error during the select statement.
|
---|
21 | false if select returned <0, which should not happen at all.
|
---|
22 | What to do if this happened?
|
---|
23 | */
|
---|
24 | #define WASTEBIN_SIZE 1000
|
---|
25 | bool EmptySockets(int *SocketDescriptor, int NumberOfDescriptors, long timeout_usec = 125000L);
|
---|
26 |
|
---|
27 | /*
|
---|
28 | GetMaxFileDescriptor returns the value of the maximal
|
---|
29 | filedescriptor from NumberOfSockets SocketDescriptors.
|
---|
30 | The maximal filedescriptor + 1 is needed for select().
|
---|
31 | */
|
---|
32 | int GetMaxFileDescriptor(unsigned int NumberOfSockets, int *SocketDescriptor);
|
---|
33 |
|
---|
34 | /*
|
---|
35 | Connect2Server connects NumberOfSockets TCP Sockets
|
---|
36 | defined by SocketDescriptor
|
---|
37 | to host defined by ServerIPaddress
|
---|
38 | starting at Port StartPort, by adding 1 to each Socket
|
---|
39 |
|
---|
40 | return value is NumberOfSockets if successful
|
---|
41 | it is zero if no Server was found and negative
|
---|
42 | when connecting didn't work.
|
---|
43 | The negative magnitude indicates which connection didn't work
|
---|
44 | */
|
---|
45 | int Connect2Server( int *SocketDescriptor,
|
---|
46 | unsigned int NumberOfSockets,
|
---|
47 | unsigned int StartPort ,
|
---|
48 | char *ServerIPaddress ,
|
---|
49 | int verbose = 0);
|
---|
50 |
|
---|
51 |
|
---|
52 | /*
|
---|
53 | CloseSockets closes NumberOfSockets TCP Sockets
|
---|
54 | indicated by SocketDescriptor and frees the associated memory.
|
---|
55 | */
|
---|
56 | int CloseSockets (int * SocketDescriptor ,
|
---|
57 | unsigned int NumberOfSockets);
|
---|
58 |
|
---|
59 |
|
---|
60 | int * OpenServerSockets (unsigned int NumberOfSockets, unsigned int StartPort) ;
|
---|
61 |
|
---|