modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
2:ce08986b18b5
Parent:
1:291a9d61e58a
Child:
7:b147c08301be
--- a/SocketInterface.h	Thu May 14 01:37:53 2015 +0000
+++ b/SocketInterface.h	Tue May 19 17:40:28 2015 +0000
@@ -16,11 +16,58 @@
  
 #ifndef SOCKETINTERFACE_H
 #define SOCKETINTERFACE_H
- 
+
+/** SocketInterface class.
+ *   This is a common interface that is shared between all sockets that connect
+ *   using the NetworkInterface.
+ */
 class SocketInterface {
 
 public:
+    /**
+     *    This enum defines the possible socket protocol families.
+     */
+    enum ProtocolFamily {
+        AF_INET,    /**< IPv4 */
+        AF_INET6,   /**< IPV6 */
+        AF_UNIX     /**< Local socket (using a file) */
+    };
+    
+    /**
+     *    This enum defines the possible socket types.
+     */
+    enum SockType {
+        SOCK_STREAM,    /**< Stream socket, generally used for TCP */
+        SOCK_DGRAM,     /**< Datagram socket, generally used for UDP */
+        SOCK_SEQPACKET, /**< Reliable sequenced packet service */
+        SOCK_RAW        /**< Raw protocols atop the network layer */
+    };
 
+    /**
+     *    Configure the socket's protocol and type.
+     *
+     *    @param protocol The protocol to use.
+     *    @param type The type of socket to use.
+     */
+    virtual int config(ProtocolFamily protocol, SockType type) = 0;
+    
+    /** 
+     *    Set blocking or non-blocking mode of the socket and a timeout on
+     *    blocking socket operations.
+     *    
+     *    @param blocking true for blocking mode, false for non-blocking mode.
+     *    @param timeout timeout in ms [Default: (1500)ms].
+     */
+    virtual void setBlocking(bool blocking, unsigned int timeout=1500) = 0;
+    
+    /*
+        "options" functions here? Not familiar with this, need to discuss
+    */
+    
+    /**
+     *    Close the socket
+     */
+    virtual void close();
 
 };