wip
Dependents: EthernetInterface_vz
Fork of Socket by
Diff: UDPSocket.h
- Revision:
- 8:9cf9c2d45264
- Parent:
- 6:cd2e5559786d
- Child:
- 10:d24738f4ef99
diff -r ac5f77f4497a -r 9cf9c2d45264 UDPSocket.h --- a/UDPSocket.h Fri Jul 27 14:22:45 2012 +0000 +++ b/UDPSocket.h Fri Jul 27 15:50:23 2012 +0000 @@ -24,29 +24,31 @@ #include <cstdint> /** -This is a C++ abstraction for UDP networking sockets. +UDP Socket */ class UDPSocket : public Socket { public: - /** Instantiate a UDP Socket. + /** Instantiate an UDP Socket. */ UDPSocket(); ~UDPSocket(); + /** Init the UDP Client Socket without binding it to any specific port + \return 0 on success, -1 on failure. + */ int init(void); /** Bind a UDP Server Socket to a specific port - For a listening socket, bind the socket to the following port. - \param port The port to listen for incoming connections on, using 0 here will select a random port. + \param port The port to listen for incoming connections on \return 0 on success, -1 on failure. */ int bind(int port); /** Send a packet to the remote host. \param packet UDP Packet to be sent to the remote host - \param timeout The maximum amount of time in ms to wait while trying to send the buffer. + \param timeout_ms The maximum amount of time in ms to wait while trying to send the packet. \return the number of written bytes on success (>=0) or -1 on failure */ int sendTo(UDPPacket& packet, int timeout_ms=0); @@ -55,7 +57,7 @@ If a message is too long to fit in the supplied packet, excess bytes are discarded. \param packet UDP Packet received from the remote host - \param timeout The maximum amount of time in ms to wait while trying to receive data. + \param timeout The maximum amount of time in ms to wait while trying to receive packet. \return the number of received bytes on success (>=0) or -1 on failure */ int receiveFrom(UDPPacket& packet, int timeout_ms=0);