@@ -42,13 +42,18 @@ class Socket {
42
42
*/
43
43
virtual nsapi_error_t close () = 0;
44
44
45
- /* * Connects socket to a remote host .
45
+ /* * Connects socket to a remote address .
46
46
*
47
- * Initiates a connection to a remote server specified by the
48
- * indicated address. In case of connectionless protocol, set
49
- * the remote address for next send() call.
47
+ * Attempt to make connection on connection-mode protocol or set or reset
48
+ * the peer address on connectionless protocol.
50
49
*
51
- * @param address The SocketAddress of the remote host
50
+ * Also connectionless protocols use the connected address to filter
51
+ * incoming packets for recv() and recvfrom() calls.
52
+ *
53
+ * To reset the peer address, zero initialised(default constructor) SocketAddress
54
+ * object have to be in the address parameter.
55
+ *
56
+ * @param address The SocketAddress of the remote peer
52
57
* @return 0 on success, negative error code on failure
53
58
*/
54
59
virtual nsapi_error_t connect (const SocketAddress &address) = 0;
@@ -75,6 +80,11 @@ class Socket {
75
80
* Receive data from connected socket or in case of connectionless socket
76
81
* this is equivalent of calling recvfrom(NULL, data, size).
77
82
*
83
+ * If socket is connected, only packets coming from connected peer address
84
+ * are accepted.
85
+ *
86
+ * @note recv() is allowed write to data buffer even if error occurs.
87
+ *
78
88
* By default, recv blocks until some data is received. If socket is set to
79
89
* non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK can be returned to
80
90
* indicate no data.
@@ -112,6 +122,11 @@ class Socket {
112
122
* Receives a data and stores the source address in address if address
113
123
* is not NULL. Returns the number of bytes written into the buffer.
114
124
*
125
+ * If socket is connected, only packets coming from connected peer address
126
+ * are accepted.
127
+ *
128
+ * @note recvfrom() is allowed write to address and data buffers even if error occurs.
129
+ *
115
130
* By default, recvfrom blocks until a datagram is received. If socket is set to
116
131
* non-blocking or times out with no data, NSAPI_ERROR_WOULD_BLOCK
117
132
* is returned.
0 commit comments