Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DnsQuery
Dependents: WizFi310_TCP_Echo_Server_Example
Fork of NetworkSocketAPI by
Diff: NetworkInterface.h
- Revision:
- 93:65a9f84862f0
- Parent:
- 92:dd5f19874adf
- Child:
- 94:644df37bb05b
--- a/NetworkInterface.h Tue Apr 19 18:23:29 2016 -0500 +++ b/NetworkInterface.h Tue Apr 19 18:23:42 2016 -0500 @@ -89,16 +89,20 @@ friend class TCPSocket; friend class TCPServer; - /** Create a socket - * @param proto The type of socket to open, TCP or UDP - * @return The alocated socket or null on failure + /** Open a socket + * @param handle Handle in which to store new socket + * @param proto Type of socket to open, NSAPI_TCP or NSAPI_UDP + * @return 0 on success, negative on failure */ - virtual void *socket_create(nsapi_protocol_t proto) = 0; + virtual int socket_open(void **handle, nsapi_protocol_t proto) = 0; - /** Destroy a socket - * @param socket Previously allocated socket + /** Close the socket + * @param handle Socket handle + * @return 0 on success, negative on failure + * @note On failure, any memory associated with the socket must still + * be cleaned up */ - virtual void socket_destroy(void *handle) = 0; + virtual int socket_close(void *handle) = 0; /** Set socket options * @param handle Socket handle @@ -147,13 +151,13 @@ virtual bool socket_is_connected(void *handle) = 0; /** Accept a new connection. - * @param handle Socket handle - * @param socket A TCPSocket instance that will handle the incoming connection. - * @return 0 on success, negative on failure. + * @param handle Handle in which to store new socket + * @param server Socket handle to server to accept from + * @return 0 on success, negative on failure * @note This call is not-blocking, if this call would block, must * immediately return NSAPI_ERROR_WOULD_WAIT */ - virtual int socket_accept(void *handle, void **connection) = 0; + virtual int socket_accept(void **handle, void *server) = 0; /** Send data to the remote host * @param handle Socket handle @@ -199,11 +203,6 @@ */ virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size) = 0; - /** Close the socket - * @param handle Socket handle - */ - virtual int socket_close(void *handle) = 0; - /** Register a callback on state change of the socket * @param handle Socket handle * @param callback Function to call on state change