mirror of https://github.com/ARMmbed/mbed-os.git
remove redundancy and maintainance overhead
parent
5837e3771e
commit
e31337dab7
|
|
@ -100,92 +100,27 @@ public:
|
||||||
*/
|
*/
|
||||||
nsapi_error_t bind(const char *address, uint16_t port);
|
nsapi_error_t bind(const char *address, uint16_t port);
|
||||||
|
|
||||||
/** Bind a specific address to a socket
|
/** @copydoc Socket::bind
|
||||||
*
|
|
||||||
* Binding a socket specifies the address and port on which to receive
|
|
||||||
* data. If the IP address is zeroed, only the port is bound.
|
|
||||||
*
|
|
||||||
* @param address Local address to bind
|
|
||||||
* @return 0 on success, negative error code on failure.
|
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t bind(const SocketAddress &address);
|
virtual nsapi_error_t bind(const SocketAddress &address);
|
||||||
|
|
||||||
/** Set blocking or non-blocking mode of the socket
|
/** @copydoc Socket::set_blocking
|
||||||
*
|
|
||||||
* Initially all sockets are in blocking mode. In non-blocking mode
|
|
||||||
* blocking operations such as send/recv/accept return
|
|
||||||
* NSAPI_ERROR_WOULD_BLOCK if they can not continue.
|
|
||||||
*
|
|
||||||
* set_blocking(false) is equivalent to set_timeout(-1)
|
|
||||||
* set_blocking(true) is equivalent to set_timeout(0)
|
|
||||||
*
|
|
||||||
* @param blocking true for blocking mode, false for non-blocking mode.
|
|
||||||
*/
|
*/
|
||||||
virtual void set_blocking(bool blocking);
|
virtual void set_blocking(bool blocking);
|
||||||
|
|
||||||
/** Set timeout on blocking socket operations
|
/** @copydoc Socket::set_timeout
|
||||||
*
|
|
||||||
* Initially all sockets have unbounded timeouts. NSAPI_ERROR_WOULD_BLOCK
|
|
||||||
* is returned if a blocking operation takes longer than the specified
|
|
||||||
* timeout. A timeout of 0 removes the timeout from the socket. A negative
|
|
||||||
* value give the socket an unbounded timeout.
|
|
||||||
*
|
|
||||||
* set_timeout(0) is equivalent to set_blocking(false)
|
|
||||||
* set_timeout(-1) is equivalent to set_blocking(true)
|
|
||||||
*
|
|
||||||
* @param timeout Timeout in milliseconds
|
|
||||||
*/
|
*/
|
||||||
virtual void set_timeout(int timeout);
|
virtual void set_timeout(int timeout);
|
||||||
|
|
||||||
/* Set socket options
|
/** @copydoc Socket::setsockopt
|
||||||
*
|
|
||||||
* setsockopt allows an application to pass stack-specific options
|
|
||||||
* to the underlying stack using stack-specific level and option names,
|
|
||||||
* or to request generic options using levels from nsapi_socket_level_t.
|
|
||||||
*
|
|
||||||
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
|
|
||||||
* and the socket is unmodified.
|
|
||||||
*
|
|
||||||
* @param level Stack-specific protocol level or nsapi_socket_level_t
|
|
||||||
* @param optname Level-specific option name
|
|
||||||
* @param optval Option value
|
|
||||||
* @param optlen Length of the option value
|
|
||||||
* @return 0 on success, negative error code on failure
|
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen);
|
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen);
|
||||||
|
|
||||||
/* Get socket options
|
/** @copydoc Socket::getsockopt
|
||||||
*
|
|
||||||
* getsockopt allows an application to retrieve stack-specific options
|
|
||||||
* from the underlying stack using stack-specific level and option names,
|
|
||||||
* or to request generic options using levels from nsapi_socket_level_t.
|
|
||||||
*
|
|
||||||
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
|
|
||||||
* and the socket is unmodified.
|
|
||||||
*
|
|
||||||
* @param level Stack-specific protocol level or nsapi_socket_level_t
|
|
||||||
* @param optname Level-specific option name
|
|
||||||
* @param optval Destination for option value
|
|
||||||
* @param optlen Length of the option value
|
|
||||||
* @return 0 on success, negative error code on failure
|
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen);
|
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen);
|
||||||
|
|
||||||
/** Register a callback on state change of the socket
|
/** @copydoc Socket::sigio
|
||||||
*
|
|
||||||
* The specified callback will be called on state changes such as when
|
|
||||||
* the socket can recv/send/accept successfully and on when an error
|
|
||||||
* occurs. The callback may also be called spuriously without reason.
|
|
||||||
*
|
|
||||||
* The callback may be called in an interrupt context and should not
|
|
||||||
* perform expensive operations such as recv/send calls.
|
|
||||||
*
|
|
||||||
* Note! This is not intended as a replacement for a poll or attach-like
|
|
||||||
* asynchronous api, but rather as a building block for constructing
|
|
||||||
* such functionality. The exact timing of when the registered function
|
|
||||||
* is called is not guaranteed and susceptible to change.
|
|
||||||
*
|
|
||||||
* @param func Function to call on state change
|
|
||||||
*/
|
*/
|
||||||
virtual void sigio(mbed::Callback<void()> func);
|
virtual void sigio(mbed::Callback<void()> func);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
* Closes any open connection and deallocates any memory associated
|
* Closes any open connection and deallocates any memory associated
|
||||||
* with the socket. Called from destructor if socket is not closed.
|
* with the socket. Called from destructor if socket is not closed.
|
||||||
*
|
*
|
||||||
* @return 0 on success, negative error code on failure
|
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t close() = 0;
|
virtual nsapi_error_t close() = 0;
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ public:
|
||||||
* object have to be in the address parameter.
|
* object have to be in the address parameter.
|
||||||
*
|
*
|
||||||
* @param address The SocketAddress of the remote peer
|
* @param address The SocketAddress of the remote peer
|
||||||
* @return 0 on success, negative error code on failure
|
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t connect(const SocketAddress &address) = 0;
|
virtual nsapi_error_t connect(const SocketAddress &address) = 0;
|
||||||
|
|
||||||
|
|
@ -142,10 +142,11 @@ public:
|
||||||
|
|
||||||
/** Bind a specific address to a socket.
|
/** Bind a specific address to a socket.
|
||||||
*
|
*
|
||||||
* Binding assigns a local address to a socket.
|
* Binding a socket specifies the address and port on which to receive
|
||||||
|
* data. If the IP address is zeroed, only the port is bound.
|
||||||
*
|
*
|
||||||
* @param address Local address to bind
|
* @param address Local address to bind
|
||||||
* @return 0 on success, negative error code on failure.
|
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t bind(const SocketAddress &address) = 0;
|
virtual nsapi_error_t bind(const SocketAddress &address) = 0;
|
||||||
|
|
||||||
|
|
@ -190,11 +191,11 @@ public:
|
||||||
* such functionality. The exact timing of when the registered function
|
* such functionality. The exact timing of when the registered function
|
||||||
* is called is not guaranteed and susceptible to change.
|
* is called is not guaranteed and susceptible to change.
|
||||||
*
|
*
|
||||||
* @param func Function to call on state change
|
* @param func Function to call on state change.
|
||||||
*/
|
*/
|
||||||
virtual void sigio(mbed::Callback<void()> func) = 0;
|
virtual void sigio(mbed::Callback<void()> func) = 0;
|
||||||
|
|
||||||
/* Set socket options.
|
/** Set socket options.
|
||||||
*
|
*
|
||||||
* setsockopt() allows an application to pass stack-specific options
|
* setsockopt() allows an application to pass stack-specific options
|
||||||
* to the underlying stack using stack-specific level and option names,
|
* to the underlying stack using stack-specific level and option names,
|
||||||
|
|
@ -203,15 +204,15 @@ public:
|
||||||
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
|
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
|
||||||
* and the socket is unmodified.
|
* and the socket is unmodified.
|
||||||
*
|
*
|
||||||
* @param level Stack-specific protocol level or nsapi_socket_level_t
|
* @param level Stack-specific protocol level or nsapi_socket_level_t.
|
||||||
* @param optname Level-specific option name
|
* @param optname Level-specific option name.
|
||||||
* @param optval Option value
|
* @param optval Option value.
|
||||||
* @param optlen Length of the option value
|
* @param optlen Length of the option value.
|
||||||
* @return 0 on success, negative error code on failure
|
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen) = 0;
|
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen) = 0;
|
||||||
|
|
||||||
/* Get socket options.
|
/** Get socket options.
|
||||||
*
|
*
|
||||||
* getsockopt() allows an application to retrieve stack-specific options
|
* getsockopt() allows an application to retrieve stack-specific options
|
||||||
* from the underlying stack using stack-specific level and option names,
|
* from the underlying stack using stack-specific level and option names,
|
||||||
|
|
@ -220,11 +221,11 @@ public:
|
||||||
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
|
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
|
||||||
* and the socket is unmodified.
|
* and the socket is unmodified.
|
||||||
*
|
*
|
||||||
* @param level Stack-specific protocol level or nsapi_socket_level_t
|
* @param level Stack-specific protocol level or nsapi_socket_level_t.
|
||||||
* @param optname Level-specific option name
|
* @param optname Level-specific option name.
|
||||||
* @param optval Destination for option value
|
* @param optval Destination for option value.
|
||||||
* @param optlen Length of the option value
|
* @param optlen Length of the option value.
|
||||||
* @return 0 on success, negative error code on failure
|
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen) = 0;
|
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen) = 0;
|
||||||
|
|
||||||
|
|
@ -250,7 +251,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param backlog Number of pending connections that can be queued
|
* @param backlog Number of pending connections that can be queued
|
||||||
* simultaneously, defaults to 1
|
* simultaneously, defaults to 1
|
||||||
* @return 0 on success, negative error code on failure
|
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t listen(int backlog = 1) = 0;
|
virtual nsapi_error_t listen(int backlog = 1) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue