Roy van Dam / NetworkAPI

Dependents:   NetRelais TCP_Client_Example TCP_Server_Example UDP_Server_Example ... more

Revision:
6:847a0b218e22
Parent:
3:d30db8752485
Child:
8:cdee0f2b6ff0
--- a/udp/socket.cpp	Wed Jul 18 14:35:02 2012 +0000
+++ b/udp/socket.cpp	Wed Jul 18 15:31:16 2012 +0000
@@ -46,6 +46,19 @@
 }
 
 int
+Socket::send(Buffer &buffer, ip::Address &address, int port)
+{
+    ip::Endpoint endpoint(address, port);
+    return this->send(buffer.pointer(), buffer.length(), endpoint);
+}
+
+int
+Socket::send(Buffer &buffer, ip::Endpoint &endpoint)
+{
+    return this->send(buffer.pointer(), buffer.length(), endpoint);
+}
+
+int
 Socket::send(void *data, size_t size, ip::Address &address, int port)
 {
     ip::Endpoint endpoint(address, port);
@@ -84,6 +97,17 @@
 }
 
 int
+Socket::receive(Buffer &buffer)
+{
+    int result = this->receive(buffer.pointer(), buffer.size());
+    if (result >= 0) {
+        buffer.setLength(result);
+    }
+    
+    return result;
+}
+
+int
 Socket::receive(void *data, size_t max_size)
 {
     return this->receive(data, max_size, this->_remote_endpoint);