source: tools/FAD/SocketFunctions/SocketFunctions.h@ 5138

Last change on this file since 5138 was 256, checked in by dneise, 14 years ago
simple daq now opens outfiles in path given in config.txt
File size: 2.0 KB
Line 
1#define MAX_NUMBER_OF_OPENED_TCP_SOCKETS 100
2
3/*
4OpenSockets opens NumberOfSockets TCP Sockets.
5a pointer to an array of SocketDescriptors is returned.
6In case of error, the NULL pointer is returned.
7
8In order to Close the Sockets and free memory call
9void CloseSockets(int * SocketDescriptors, unsigned int NumberOfSockets);
10*/
11int * 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
25bool 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*/
32int GetMaxFileDescriptor(unsigned int NumberOfSockets, int *SocketDescriptor);
33
34/*
35Connect2Server connects NumberOfSockets TCP Sockets
36defined by SocketDescriptor
37to host defined by ServerIPaddress
38starting at Port StartPort, by adding 1 to each Socket
39
40return value is NumberOfSockets if successful
41it is zero if no Server was found and negative
42when connecting didn't work.
43The negative magnitude indicates which connection didn't work
44*/
45int Connect2Server( int *SocketDescriptor,
46 unsigned int NumberOfSockets,
47 unsigned int StartPort ,
48 char *ServerIPaddress ,
49 int verbose = 0);
50
51
52/*
53CloseSockets closes NumberOfSockets TCP Sockets
54indicated by SocketDescriptor and frees the associated memory.
55*/
56int CloseSockets (int * SocketDescriptor ,
57 unsigned int NumberOfSockets);
58
59
Note: See TracBrowser for help on using the repository browser.