ap

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
58:1caa187fa5af
Parent:
57:3c873fab4207
Child:
65:ca337f9ebdab
--- a/Socket.cpp	Thu Feb 25 19:00:39 2016 -0600
+++ b/Socket.cpp	Thu Feb 25 21:20:25 2016 -0600
@@ -33,60 +33,6 @@
     }
 }
 
-int32_t Socket::setURL(const char *url)
-{
-    int32_t err = _iface->getHostByName(url, _ip_address);
-    if (err) {
-        return err;
-    }
-
-    if (_socket) {
-        _socket->setIPAddress(_ip_address);
-    }
-
-    return 0;
-}
-
-void Socket::setIPAddress(const char *ip)
-{
-    strcpy(_ip_address, ip);
-
-    if (_socket) {
-        _socket->setIPAddress(_ip_address);
-    }
-}
-
-void Socket::setPort(uint16_t port)
-{
-    _port = port;
-
-    if (_socket) {
-        _socket->setPort(_port);
-    }
-}
-
-const char *Socket::getIPAddress() const
-{
-    if (_ip_address[0]) {
-        return _ip_address;
-    } else {
-        return 0;
-    }
-}
-
-uint16_t Socket::getPort() const
-{
-    return _port;
-}
-
-bool Socket::isConnected()
-{
-    if (!_socket) {
-        return false;
-    }
-
-    return _socket->isConnected();
-}
 
 int32_t Socket::open(const char *address, uint16_t port)
 {
@@ -97,19 +43,10 @@
         return err;
     }
 
-    if (address) {
-        err = setURL(address);
-        if (err) {
-            return err;
-        }
-    }
-
-    if (port) {
-        setPort(port);
-    }
-
-    if (!getIPAddress() || !getPort()) {
-        return NS_ERROR_NO_ADDRESS;
+    err = _iface->getHostByName(address, _ip_address);
+    _port = port;
+    if (err) {
+        return err;
     }
 
     _socket = _iface->createSocket(_proto);
@@ -166,3 +103,27 @@
     }
 }
 
+
+const char *Socket::getIPAddress() const
+{
+    if (_ip_address[0]) {
+        return _ip_address;
+    } else {
+        return 0;
+    }
+}
+
+uint16_t Socket::getPort() const
+{
+    return _port;
+}
+
+bool Socket::isConnected()
+{
+    if (!_socket) {
+        return false;
+    }
+
+    return _socket->isConnected();
+}
+