NetworkSocketAPI
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Revision 24:a5e959bdd2dd, committed 2016-02-18
- Comitter:
- Christopher Haster
- Date:
- Thu Feb 18 04:09:00 2016 -0600
- Branch:
- api-changes
- Parent:
- 23:1e86d9fb3d86
- Child:
- 25:ed7b2a52e8ac
- Commit message:
- Added setURL for DNS lookups
Changed in this revision
--- a/SocketInterface.h Thu Feb 18 04:05:09 2016 -0600 +++ b/SocketInterface.h Thu Feb 18 04:09:00 2016 -0600 @@ -40,6 +40,12 @@ virtual ~SocketInterface(); + /** Set the URL of the socket + * Performs DNS lookup if necessary + * @param url URL to connect to + */ + virtual void setURL(const char *url) = 0; + /** Set the IP address of the socket * @param ip IP address to connect to, copied internally */
--- a/TCPSocket.cpp Thu Feb 18 04:05:09 2016 -0600 +++ b/TCPSocket.cpp Thu Feb 18 04:09:00 2016 -0600 @@ -28,6 +28,10 @@ _iface->destroySocket(_socket); } +void TCPSocket::setURL(const char *url) { + return _socket->setURL(url); +} + void TCPSocket::setIPAddress(const char *ip) { return _socket->setIPAddress(ip); }
--- a/TCPSocket.h Thu Feb 18 04:05:09 2016 -0600 +++ b/TCPSocket.h Thu Feb 18 04:09:00 2016 -0600 @@ -28,16 +28,22 @@ public: /** Create a socket using the specified network interface * @param iface The network interface to use - * @param ip Optional ip address to connect to, copied internally + * @param ip Optional URL to connect to, copied internally * @param port Optional port to connect to */ - TCPSocket(NetworkInterface *iface, const char *ip = 0, uint16_t port = 0); + TCPSocket(NetworkInterface *iface, const char *url = 0, uint16_t port = 0); /** Closes and destroys the socket */ ~TCPSocket(); + /** Set the URL of the socket + * Performs DNS lookup if necessary + * @param url URL to connect to + */ + void setURL(const char *url); + /** Set the IP address of the socket * @param ip IP address to connect to, copied internally */
--- a/UDPSocket.cpp Thu Feb 18 04:05:09 2016 -0600 +++ b/UDPSocket.cpp Thu Feb 18 04:09:00 2016 -0600 @@ -16,11 +16,11 @@ #include "UDPSocket.h" -UDPSocket::UDPSocket(NetworkInterface *iface, const char *ip, uint16_t port) +UDPSocket::UDPSocket(NetworkInterface *iface, const char *url, uint16_t port) : _iface(iface) { _socket = _iface->createSocket(SOCK_UDP); - if (ip) setIPAddress(ip); + if (url) setURL(url); if (port) setPort(port); } @@ -28,6 +28,10 @@ _iface->destroySocket(_socket); } +void UDPSocket::setURL(const char *url) { + return _socket->setURL(url); +} + void UDPSocket::setIPAddress(const char *ip) { return _socket->setIPAddress(ip); }
--- a/UDPSocket.h Thu Feb 18 04:05:09 2016 -0600 +++ b/UDPSocket.h Thu Feb 18 04:09:00 2016 -0600 @@ -28,16 +28,22 @@ public: /** Create a socket using the specified network interface * @param iface The network interface to use - * @param ip Optional ip address to connect to, copied internally + * @param ip Optional URL to connect to, copied internally * @param port Optional port to connect to */ - UDPSocket(NetworkInterface *iface, const char *ip = 0, uint16_t port = 0); + UDPSocket(NetworkInterface *iface, const char *url = 0, uint16_t port = 0); /** Closes and destroys the socket */ ~UDPSocket(); + /** Set the URL of the socket + * Performs DNS lookup if necessary + * @param url URL to connect to + */ + void setURL(const char *url); + /** Set the IP address of the socket * @param ip IP address to connect to, copied internally */