mirror of https://github.com/ARMmbed/mbed-os.git
editorial changes, punctuation
parent
fcd497303d
commit
ea296afec2
|
@ -28,23 +28,23 @@
|
|||
/** Socket interface.
|
||||
*
|
||||
* This class defines the Mbed OS Socket API.
|
||||
* Socket is an abstract interface for communicating to remote endpoints.
|
||||
* Socket is an abstract interface for communicating with remote endpoints.
|
||||
*
|
||||
* This API is intented to use for applications and libraries instead of
|
||||
* using some protocol specific implementation of it. For example TCPSocket
|
||||
* and UDPSocket are implementations of Socket interface.
|
||||
* Socket API is intentionally not protocol specific and allows all protocol
|
||||
* to provide same API regardless of underlying transport mechanism.
|
||||
* This API is intented for applications and libraries instead of
|
||||
* protocol-specific implementations. For example, TCPSocket
|
||||
* and UDPSocket are implementations of the Socket interface.
|
||||
* Socket API is intentionally not protocol-specific, and allows all protocol
|
||||
* to provide the same API regardless of the underlying transport mechanism.
|
||||
*/
|
||||
class Socket {
|
||||
public:
|
||||
/** Destroy a socket.
|
||||
*
|
||||
* Closes socket if the socket is still open
|
||||
* Closes socket if the socket is still open.
|
||||
*/
|
||||
virtual ~Socket() {}
|
||||
|
||||
/** Close the socket.
|
||||
/** Closes the socket.
|
||||
*
|
||||
* Closes any open connection and deallocates any memory associated
|
||||
* with the socket. Called from destructor if socket is not closed.
|
||||
|
@ -55,17 +55,17 @@ public:
|
|||
|
||||
/** Connects socket to a remote address.
|
||||
*
|
||||
* Attempt to make connection on connection-mode protocol or set or reset
|
||||
* Attempts to make connection on connection-mode protocol or set or reset
|
||||
* the peer address on connectionless protocol.
|
||||
*
|
||||
* Also connectionless protocols use the connected address to filter
|
||||
* Connectionless protocols also use the connected address to filter
|
||||
* incoming packets for recv() and recvfrom() calls.
|
||||
*
|
||||
* To reset the peer address, zero initialized(default constructor) SocketAddress
|
||||
* object have to be in the address parameter.
|
||||
* To reset the peer address, there must be zero initialized(default constructor) SocketAddress
|
||||
* objects in the address parameter.
|
||||
*
|
||||
* @param address The SocketAddress of the remote peer
|
||||
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
||||
* @param address The SocketAddress of the remote peer.
|
||||
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||
*/
|
||||
virtual nsapi_error_t connect(const SocketAddress &address) = 0;
|
||||
|
||||
|
@ -73,14 +73,14 @@ public:
|
|||
*
|
||||
* The socket must be connected to a remote host before send() call.
|
||||
* Returns the number of bytes sent from the buffer.
|
||||
* In case of connectionless socket, send data to pre-specified remote.
|
||||
* In case of connectionless socket, sends data to pre-specified remote.
|
||||
*
|
||||
* By default, send blocks until all data is sent. If socket is set to
|
||||
* non-blocking or times out, a partial amount can be written.
|
||||
* NSAPI_ERROR_WOULD_BLOCK is returned if no data was written.
|
||||
*
|
||||
* @param data Buffer of data to send to the host
|
||||
* @param size Size of the buffer in bytes
|
||||
* @param data Buffer of data to send to the host.
|
||||
* @param size Size of the buffer in bytes.
|
||||
* @return Number of sent bytes on success, negative error
|
||||
* code on failure.
|
||||
*/
|
||||
|
@ -88,20 +88,20 @@ public:
|
|||
|
||||
/** Receive data from a socket.
|
||||
*
|
||||
* Receive data from connected socket or in case of connectionless socket
|
||||
* this is equivalent of calling recvfrom(NULL, data, size).
|
||||
* Receive data from connected socket, or in the case of connectionless socket,
|
||||
* equivalent to calling recvfrom(NULL, data, size).
|
||||
*
|
||||
* If socket is connected, only packets coming from connected peer address
|
||||
* are accepted.
|
||||
*
|
||||
* @note recv() is allowed write to data buffer even if error occurs.
|
||||
* @note recv() is allowed write to data buffer even if an error occurs.
|
||||
*
|
||||
* By default, recv blocks until some data is received. If socket is set to
|
||||
* non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK can be returned to
|
||||
* indicate no data.
|
||||
*
|
||||
* @param data Destination buffer for data received from the host
|
||||
* @param size Size of the buffer in bytes
|
||||
* @param data Destination buffer for data received from the host.
|
||||
* @param size Size of the buffer in bytes.
|
||||
* @return Number of received bytes on success, negative error
|
||||
* code on failure. If no data is available to be received
|
||||
* and the peer has performed an orderly shutdown,
|
||||
|
@ -111,9 +111,9 @@ public:
|
|||
|
||||
/** Send a message on a socket.
|
||||
*
|
||||
* The sendto() function shall send a message through a connection-mode or connectionless-mode socket.
|
||||
* If the socket is connectionless-mode, the message shall be sent to the address specified.
|
||||
* If the socket is connection-mode, address shall be ignored.
|
||||
* The sendto() function sends a message through a connection-mode or connectionless-mode socket.
|
||||
* If the socket is in connectionless-mode, the message is sent to the address specified.
|
||||
* If the socket is in connection-mode, address is ignored.
|
||||
*
|
||||
* By default, sendto blocks until data is sent. If socket is set to
|
||||
* non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
* 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 NSAPI_ERROR_OK on success, negative error code on failure.
|
||||
*/
|
||||
virtual nsapi_error_t bind(const SocketAddress &address) = 0;
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
*
|
||||
* 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.
|
||||
* NSAPI_ERROR_WOULD_BLOCK if they cannot continue.
|
||||
*
|
||||
* set_blocking(false) is equivalent to set_timeout(0)
|
||||
* set_blocking(true) is equivalent to set_timeout(-1)
|
||||
|
@ -179,7 +179,7 @@ public:
|
|||
* 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.
|
||||
* value gives the socket an unbounded timeout.
|
||||
*
|
||||
* set_timeout(0) is equivalent to set_blocking(false)
|
||||
* set_timeout(-1) is equivalent to set_blocking(true)
|
||||
|
@ -190,17 +190,17 @@ public:
|
|||
|
||||
/** Register a callback on state change of the socket.
|
||||
*
|
||||
* The specified callback will be called on state changes such as when
|
||||
* the socket can recv/send/accept successfully and on when an error
|
||||
* The specified callback is called on state changes, such as when
|
||||
* the socket can receive/send/accept successfully and 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.
|
||||
* perform expensive operations such as receive/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.
|
||||
* asynchronous API, but rather as a building block for constructing
|
||||
* such functionality. The exact timing of the registered function
|
||||
* is not guaranteed and susceptible to change.
|
||||
*
|
||||
* @param func Function to call on state change.
|
||||
*/
|
||||
|
@ -243,15 +243,15 @@ public:
|
|||
/** Accepts a connection on a socket.
|
||||
*
|
||||
* The server socket must be bound and set to listen for connections.
|
||||
* On a new connection, returns connected network socket which user is expected to call close()
|
||||
* and that deallocates the resources. Referencing a returned pointer after a close()
|
||||
* On a new connection, returns connected network socket to call close()
|
||||
* that deallocates the resources. Referencing a returned pointer after a close()
|
||||
* call is not allowed and leads to undefined behavior.
|
||||
*
|
||||
* By default, accept blocks until incoming connection occurs. If socket is set to
|
||||
* non-blocking or times out, error is set to NSAPI_ERROR_WOULD_BLOCK.
|
||||
*
|
||||
* @param error pointer to storage of the error value or NULL
|
||||
* @return pointer to a socket
|
||||
* @param error Pointer to storage of the error value or NULL.
|
||||
* @return Pointer to a socket.
|
||||
*/
|
||||
virtual Socket *accept(nsapi_error_t *error = NULL) = 0;
|
||||
|
||||
|
@ -261,8 +261,8 @@ public:
|
|||
* incoming connections.
|
||||
*
|
||||
* @param backlog Number of pending connections that can be queued
|
||||
* simultaneously, defaults to 1
|
||||
* @return NSAPI_ERROR_OK on success, negative error code on failure
|
||||
* simultaneously, defaults to 1.
|
||||
* @return NSAPI_ERROR_OK on success, negative error code on failure.
|
||||
*/
|
||||
virtual nsapi_error_t listen(int backlog = 1) = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue