Mercurial > hg > beaglert
comparison include/UdpServer.h @ 121:2197435e8fb4 scope-refactoring
UdpServer : read and waitUntilReady are now somehow Juce-compliant
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 22 Aug 2015 01:20:35 +0100 |
parents | f5b5c648cd5d |
children | 719119fb2905 |
comparison
equal
deleted
inserted
replaced
120:cdd441a304a9 | 121:2197435e8fb4 |
---|---|
23 int port; | 23 int port; |
24 int enabled; | 24 int enabled; |
25 int inSocket; | 25 int inSocket; |
26 struct sockaddr_in server; | 26 struct sockaddr_in server; |
27 struct timeval stTimeOut; | 27 struct timeval stTimeOut; |
28 struct timeval stZeroTimeOut; | |
28 fd_set stReadFDS; | 29 fd_set stReadFDS; |
29 int size; | 30 int size; |
30 void *wasteBuffer; | 31 void *wasteBuffer; |
31 int wasteBufferSize; | 32 int wasteBufferSize; |
32 int length; | 33 int length; |
37 UdpServer(int aPort); | 38 UdpServer(int aPort); |
38 ~UdpServer(); | 39 ~UdpServer(); |
39 bool init(int aPort); | 40 bool init(int aPort); |
40 bool bindToPort(int aPort); | 41 bool bindToPort(int aPort); |
41 int getBoundPort() const; | 42 int getBoundPort() const; |
42 int read(void *destBuffer, | 43 /* |
43 int maxBytesToRead); | 44 * Reads bytes from the socket. |
45 * | |
46 * Drop-in replacement for JUCE DatagramSocket::read() | |
47 * | |
48 If blockUntilSpecifiedAmountHasArrived is true, the method will block until maxBytesToRead | |
49 bytes have been read, (or until an error occurs). If this flag is false, the method will | |
50 return as much data as is currently available without blocking. | |
51 */ | |
52 int read(void* destBuffer, int maxBytesToRead, bool blockUntilSpecifiedAmountHasArrived); | |
44 int emptySocket(); | 53 int emptySocket(); |
45 int emptySocket(int maxBytes); | 54 int emptySocket(int maxBytes); |
46 void *getWaste(); | 55 void *getWaste(); |
56 /* | |
57 * Waits until the socket is ready for reading or writing. | |
58 * | |
59 Drop-in replacement for JUCE DatagramSocket::waitUntilReady. | |
60 If readyForReading is true, it will wait until the socket is ready for reading; if false, it will wait until it's ready for writing. | |
61 If the timeout is < 0, it will wait forever, or else will give up after the specified time. | |
62 If the socket is ready on return, this returns 1. If it times-out before the socket becomes ready, it returns 0. If an error occurs, it returns -1. | |
63 */ | |
64 int waitUntilReady(bool readyForReading, int timeoutMsecs); | |
47 }; | 65 }; |
48 | 66 |
49 | 67 |
50 | 68 |
51 #endif /* UDPSERVER_H_ */ | 69 #endif /* UDPSERVER_H_ */ |