ap

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Branch:
api-changes
Revision:
28:163fbe3263f4
Parent:
27:d7ed39727306
Child:
32:2c5fc105fc50
--- a/Socket.h	Thu Feb 18 09:20:39 2016 -0600
+++ b/Socket.h	Thu Feb 18 13:19:47 2016 -0600
@@ -29,14 +29,16 @@
     /** Set the URL of the socket
      *  Performs DNS lookup if necessary
      *  @param url URL to connect to
+     *  @param port Optional port to connect to
      *  @return 0 on success
      */
-    int32_t setURL(const char *url);
+    int32_t setURL(const char *url, uint16_t port = 0);
 
     /** Set the IP address of the socket
      *  @param ip IP address to connect to, copied internally
+     *  @param port Optional port to connect to
      */
-    void setIPAddress(const char *ip);
+    void setIPAddress(const char *ip, uint16_t port = 0);
 
     /** Set the port of the socket
      *  @param port Port to connect to
@@ -46,12 +48,12 @@
     /** Gets the IP address
      *  @return IP address to connect to
      */
-    const char *getIPAddress();
+    const char *getIPAddress() const;
 
     /** Gets the port
      *  @return Port to connect to
      */
-    uint16_t getPort();
+    uint16_t getPort() const;
 
 
     /** Send data over the socket
@@ -72,10 +74,7 @@
 
 
 protected:
-    Socket( NetworkInterface *iface,
-            socket_protocol_t proto, 
-            const char *url = 0,
-            uint16_t port = 0);
+    Socket(NetworkInterface *iface, socket_protocol_t proto);
     ~Socket();
 
     SocketInterface *_get_socket();
@@ -85,9 +84,8 @@
     socket_protocol_t _proto;
     SocketInterface *_socket;
 
-    char *_pending_url;
-    char *_pending_ip;
-    uint16_t _pending_port;
+    char _ip_address[SOCK_IP_SIZE];
+    uint16_t _port;
 };
 
 #endif