pefect / NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
11:47c32687a44c
Parent:
9:26b257519de9
Child:
12:ab3679eb4d9d
--- a/SocketInterface.h	Wed Jul 15 15:41:11 2015 +0000
+++ b/SocketInterface.h	Wed Jul 15 23:21:17 2015 +0000
@@ -52,42 +52,44 @@
         @param name The name of a host you need an ip address for
         @return The ip address of the host otherwise NULL
      */
-    virtual const char *get_host_by_name(const char *name) const = 0;
+    virtual const char *getHostByName(const char *name) const = 0;
     
     /** Set the address of this endpoint
         @param addr The endpoint address
         @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
      */
-    virtual int32_t set_address(const char* addr) const = 0;
+    virtual int32_t setAddress(const char* addr) const = 0;
 
     /** Set the port of this endpoint
         @param port The endpoint port
         @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
      */
-    virtual int32_t set_port(uint16_t port) const = 0;
+    virtual int32_t setPort(uint16_t port) const = 0;
 
     /** Set the address and port of this endpoint
         @param addr The endpoint address (supplied as an ip address).
         @param port The endpoint port
         @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
      */
-    virtual int32_t set_address_port(const char* addr, uint16_t port) const = 0;
+    virtual int32_t setAddressPort(const char* addr, uint16_t port) const = 0;
 
     /** Get the IP address of this endpoint
         @return The IP address of this endpoint.
      */
-    virtual const char *get_address(void) const = 0;
+    virtual const char *getAddress(void) const = 0;
 
     /** Get the port of this endpoint
         @return The port of this socket
      */
-    virtual uint16_t get_port(void) const = 0;
+    virtual uint16_t getPort(void) const = 0;
 
 };
 
-/** Base class that defines a TCP/UDPSocket endpoint
+/** SocketInterface class.
+ *   This is a common interface that is shared between all sockets that connect
+ *   using the NetworkInterface.
  */
-class Socket : public Endpoint
+class SocketInterface : public Endpoint
 {
 public:
     /** In server mode, set which port to listen on
@@ -105,13 +107,13 @@
         @param endpoint The endpoint we are listening to
         @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
      */
-    virtual int32_t accept(const Endpoint &endpoint) const = 0;
+    virtual int32_t accept() const = 0;
 
     /** In client mode, open a connection to a remote host
         @param endpoint The endpoint we want to connect to
         @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
      */
-    virtual int32_t open(const Endpoint &endpoint) const = 0;
+    virtual int32_t open() const = 0;
     
     /** In client or server mode send data
         @param data A buffer of data to send
@@ -133,18 +135,11 @@
         @param endpoint The endpoint we want to connect to 
         @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
      */
-    virtual int32_t close(const Endpoint &endpoint) const = 0;
-
-};
-
-/** SocketInterface class.
- *   This is a common interface that is shared between all sockets that connect
- *   using the NetworkInterface.
- */
-class SocketInterface : public Socket
-{
-public:
-    // do something to specify TCP/UDP here
+    virtual int32_t close() const = 0;
+    
+protected:
+    /** The socket's unique handle number. Used to quickly create and destroy sockets within NetworkInterfaces. */
+    uint32_t handle;
 };
 
 #endif