mbed socket API

Dependents:   EthernetInterface EthernetInterface_RSF EthernetInterface EthernetInterface ... more

Deprecated

This is an mbed 2 sockets library. For mbed 5, network sockets have been revised to better support additional network stacks and thread safety here.

Revision:
11:3d83c348fb8b
Parent:
10:d24738f4ef99
Child:
16:2d471deff212
--- a/UDPSocket.h	Tue Jul 31 11:50:55 2012 +0000
+++ b/UDPSocket.h	Wed Aug 01 13:02:32 2012 +0000
@@ -20,7 +20,8 @@
 #define UDPSOCKET_H
 
 #include "Socket/Socket.h"
-#include "Socket/UDPPacket.h"
+#include "Socket/Endpoint.h"
+
 #include <cstdint>
 
 /**
@@ -33,8 +34,6 @@
     */
     UDPSocket();
     
-    ~UDPSocket();
-    
     /** Init the UDP Client Socket without binding it to any specific port
     \return 0 on success, -1 on failure.
     */
@@ -46,19 +45,22 @@
     */
     int bind(int port);
     
-    /** Send a packet to the remote host.
-    \param packet UDP Packet to be sent to the remote host
+    /** Send a packet to a remote endpoint
+    \param remote   The remote endpoint
+    \param packet   The packet to be sent
+    \param length   The length of the packet to be sent
     \return the number of written bytes on success (>=0) or -1 on failure
     */
-    int sendTo(UDPPacket& packet);
+    int sendTo(Endpoint &remote, char *packet, int length);
     
-    /** Receive data from a remote host.
-    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
+    /** Receive a packet from a remote endpoint
+    \param remote   The remote endpoint
+    \param buffer   The buffer for storing the incoming packet data. If a packet
+           is too long to fit in the supplied buffer, excess bytes are discarded
+    \param length   The length of the buffer
     \return the number of received bytes on success (>=0) or -1 on failure
     */
-    int receiveFrom(UDPPacket& packet);
+    int receiveFrom(Endpoint &remote, char *buffer, int length);
 };
 
-#endif 
+#endif