remove link in brief tag
[platform/framework/native/net.git] / inc / FNetSockSocket.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18
19 /**
20 * @file         FNetSockSocket.h
21 * @brief        This is the header file for the %Socket class.
22 *
23 * This header file contains the declarations of the %Socket class. @n
24 * This class is a base class that provides methods for sending and receiving the data over a network.
25 */
26
27 #ifndef _FNET_SOCK_SOCKET_H_
28 #define _FNET_SOCK_SOCKET_H_
29
30 #include <FBaseObject.h>
31 #include <FNetNetEndPoint.h>
32 #include <FNetNetConnection.h>
33 #include <FNetSockSocketTypes.h>
34 #include <FNetSockSocketLingerOption.h>
35 #include <FNetSockSocketIpMulticastRequestOption.h>
36 #include <FNetSockISocketEventListener.h>
37
38 namespace Tizen { namespace Net { namespace Sockets
39 {
40
41 class _SocketImpl;
42
43 /**
44 * @class        Socket
45 * @brief        This class is the base class that provides simple methods for sending and receiving the data over a network.
46 *
47 * @since    2.0
48 *
49 * The %Socket class is the base class that provides simple methods for sending and receiving the data over a network.
50 *
51 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
52 */
53 class _OSP_EXPORT_ Socket
54         : public Tizen::Base::Object
55 {
56
57 public:
58         /**
59         * The object is not fully constructed after this constructor is called. @n
60         * For full construction, the Construct() method must be called right after calling this constructor.
61         *
62         * @since        2.0
63         */
64         Socket(void);
65
66         /**
67         * This destructor overrides Tizen::Base::Object::~Object().
68         *
69         * @since        2.0
70         *
71         * @see          Close()
72         */
73         virtual ~Socket(void);
74
75         /**
76         * Initializes this instance of %Socket with the specified parameters. @n
77         * The socket is initialized in a non-blocking mode by default.
78         * Use Ioctl() (with NET_SOCKET_FIONBIO) to use a %Socket in the blocking mode.
79         *
80         * @since                        2.0
81         * @privlevel            public
82         * @privilege            %http://tizen.org/privilege/socket
83         *
84         * @return               An error code
85         * @param[in]    netConnection                           A run-time session where a %Socket instance is used
86         * @param[in]    addressFamily                           A ::NetSocketAddressFamily value
87         * @param[in]    socketType                                      A ::NetSocketType value
88         * @param[in]    protocol                                        A ::NetSocketProtocol value
89         * @exception    E_SUCCESS                                       The method is successful.
90         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
91         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
92         * @exception    E_MAX_EXCEEDED                  All sockets are in use.
93         * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
94         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
95         * @exception    E_UNSUPPORTED_PROTOCOL  The protocol is not supported.
96         * @exception    E_UNSUPPORTED_TYPE              The socket type is not supported.
97         * @exception    E_UNSUPPORTED_FAMILY            The address family is not supported.
98         * @exception    E_SYSTEM                                        A system error has occurred.
99         * @exception    E_INVALID_CONNECTION            The network connection is invalid.
100         * @exception    E_FAILURE                                       The method has failed.
101         * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
102         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
103         * @remarks      The @c netConnection parameter specifies a run-time network connection. @n
104         *                               The @c addressFamily parameter specifies an address family. @n
105         *                               The @c socketType parameter specifies the type of the socket. @n
106         *                               The @c protocol parameter specifies the protocol used by the socket. @n
107         *                               The first parameter must be a valid run-time network connection.
108         *                               The three parameters (without @c netConnection) are not independent.
109         *                               Some address families restrict the protocols that can be used with them,
110         *                               and often the socket type is implicit in the protocol.
111         *                               If the combination of the address family, socket type, and protocol type results in
112         *                               an invalid socket, this method returns an error. @n
113         *                               This method is used for a socket of the type NET_SOCKET_PROTOCOL_TCP, NET_SOCKET_PROTOCOL_UDP, or NET_SOCKET_PROTOCOL_SSL. @n
114         *                               If the blocking mode is being used, and a method call is made which does not
115         *                               complete immediately, the application blocks the execution until the requested operation is completed. @n@n
116         *                               If the execution is to be continued even though the requested operation
117         *                               is not complete, the non-blocking mode should be used, which is the default mode in this method. @n
118         *                               For each socket used in the non-blocking mode, an event listener (ISocketEventListener) should be registered
119         *                               and maintained, so that it can receive asynchronous notifications of the socket events. @n
120         *                               To register the listener, AddSocketListener() should be used after calling this method. @n
121         *                               If a socket in the blocking mode needs to be used, Ioctl() (with NET_SOCKET_FIONBIO) should be called after initializing the socket
122         *                               through this method.
123         * @see                  Ioctl() for understanding the blocking/non-blocking mode
124         */
125         result Construct(const NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
126
127         /**
128         * Initializes this instance of %Socket with the specified parameters. @n
129         * The socket is initialized in a non-blocking mode by default.
130         * Use Ioctl() (with NET_SOCKET_FIONBIO) to use a %Socket in the blocking mode.
131         *
132         * @since                        2.0
133         * @privlevel            public
134         * @privilege            %http://tizen.org/privilege/socket
135         *
136         * @return               An error code
137         * @param[in]    addressFamily                           A ::NetSocketAddressFamily value
138         * @param[in]    socketType                                      A ::NetSocketType value
139         * @param[in]    protocol                                        A ::NetSocketProtocol value
140         * @exception    E_SUCCESS                                       The method is successful.
141         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
142         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
143         * @exception    E_MAX_EXCEEDED                          All sockets are in use.
144         * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
145         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
146         * @exception    E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
147         * @exception    E_UNSUPPORTED_TYPE                      The socket type is not supported.
148         * @exception    E_UNSUPPORTED_FAMILY            The address family is not supported.
149         * @exception    E_SYSTEM                                        A system error has occurred.
150         * @exception    E_INVALID_CONNECTION            The network connection is invalid.
151         * @exception    E_FAILURE                                       The method has failed.
152         * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
153         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
154         * @remarks              The @c addressFamily parameter specifies an address family. @n
155         *                               The @c socketType parameter specifies the type of the socket. @n
156         *                               The @c protocol parameter specifies the protocol used by the socket. @n
157         *                               The three parameters are not independent.
158         *                               Some address families restrict the protocols that can be used with them,
159         *                               and often the socket type is implicit in the protocol.
160         *                               If the combination of the address family, socket type, and protocol type results in
161         *                               an invalid socket, this method returns an error. @n
162         *                               This method is used for a socket of the type NET_SOCKET_PROTOCOL_TCP, NET_SOCKET_PROTOCOL_UDP, or NET_SOCKET_PROTOCOL_SSL. @n
163         *                               If the blocking mode is being used, and a method call is made which does not
164         *                               complete immediately, the application blocks the execution
165         *                               until the requested operation is completed. @n@n
166         *                               If the execution is to be continued even though the requested operation
167         *                               is not complete, the non-blocking mode should be used, which is the default mode in this method. @n
168         *                               For each socket used in the non-blocking mode, an event listener (ISocketEventListener) should be registered
169         *                               and maintained, so that it can receive asynchronous notifications of the socket events. @n
170         *                               To register the listener, AddSocketListener() should be used after calling this method. @n
171         *                               If a socket in the blocking mode needs to be used, Ioctl (with NET_SOCKET_FIONBIO) should be called after initializing the socket
172         *                               through this method.
173         * @see                  Ioctl() for understanding the blocking/non-blocking mode
174         */
175         result Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
176
177 public:
178         /**
179         * Closes the socket. @n
180         * All the resources associated with the socket are freed.
181         *
182         * @since                        2.0
183         * @privlevel            public
184         * @privilege            %http://tizen.org/privilege/socket
185         *
186         * @return               An error code
187         * @exception    E_SUCCESS                                       The method is successful.
188         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
189         * @exception    E_INVALID_SOCKET                        The socket is invalid.
190         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
191         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
192         * @exception    E_SYSTEM                                        A system error has occurred.
193         * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
194         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
195         * @remarks              If the %Socket class is not initialized through one of the Construct() methods, or this method is called more than once,
196         *                               then this method returns E_INVALID_STATE.
197         */
198         result Close(void);
199
200         /**
201         * Establishes a connection to a remote host for a connection-oriented socket. @n
202         * This socket is of the type NET_SOCKET_TYPE_STREAM.
203         *
204         * @if OSPCOMPAT
205         * @brief <i> [Compatibility] </i>
206         * @endif
207         * @since            2.0
208         * @if OSPCOMPAT
209     * @compatibility    This method has compatibility issues with OSP compatible applications. @n
210     *                   For more information, see @ref SocketConnectPage "here".
211     * @endif
212         * @privlevel            public
213         * @privilege            %http://tizen.org/privilege/socket
214         *
215         * @return                       An error code
216         * @param[in]            remoteEndPoint                          An instance of NetEndPoint representing the remote device
217         * @exception            E_SUCCESS                                       The method is successful.
218         * @exception            E_INVALID_SOCKET                        The socket is invalid.
219         * @exception            E_INVALID_STATE                         The socket is not in a valid state.
220         * @exception            E_HOST_UNREACHABLE                      The network cannot be reached from this host at this time.
221         * @exception            E_IN_PROGRESS                           A previous request is in progress.
222         * @exception            E_INVALID_ARG                           The specified input parameter is invalid.
223         * @exception            E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
224         * @exception            E_CONNECTION_FAILED                     The socket is not connected.
225         * @exception            E_TIMEOUT                                       An attempt to connect to the server has timed out.
226         * @exception            E_ALREADY_CONNECTED                     The socket is already connected.
227         * @exception            E_UNSUPPORTED_FAMILY            The address family is not supported.
228         * @exception            E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
229         * @exception        E_OUT_OF_MEMORY                             The memory is insufficient.
230         * @exception            E_SYSTEM                                        A system error has occurred.
231         * @exception        E_PRIVILEGE_DENIED                  The application does not have the privilege to call this method.
232         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
233         * @remarks                      If the socket is a connectionless socket (that is, of the type NET_SOCKET_TYPE_DATAGRAM), this method fails.
234         *                                       After this method is called, ISocketEventListener::OnSocketConnected() is called. the data can be sent to and received from the remote device using Send() and Receive() respectively.
235         *                                       If a connection-oriented protocol is used and Bind() is not called before calling this method, the underlying service provider
236         *                                       assigns the local network address and port number.
237         */
238         result Connect(const Tizen::Net::NetEndPoint& remoteEndPoint);
239
240         /**
241     * @page                     SocketConnectPage        Compatibility for Connect()
242     *
243     * @section          SocketConnectPageIssueSection Issues
244     * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
245     * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
246     *
247     * @section          SocketConnectPageResolutionSection Resolutions
248     *  The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
249     *  -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
250     */
251
252         /**
253         * Sends the data to a socket of the type ::NET_SOCKET_TYPE_STREAM.
254         *
255         * @since        2.0
256         *
257         * @return               An error code
258         * @param[in]    buffer                                          An instance of Tizen::Base::ByteBuffer that contains the data to send
259         * @exception    E_SUCCESS                                       The method is successful.
260         * @exception    E_INVALID_SOCKET                        The socket is invalid.
261         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
262         * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
263         * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
264         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
265         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
266         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
267         * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
268         * @exception  E_OUT_OF_MEMORY                           The memory is insufficient.
269         * @exception    E_SYSTEM                                        A system error has occurred.
270         * @remarks              This method sends the data to the remote host specified in the Connect() or AcceptN() method.
271         *                               This method sends the data in the @c buffer parameter, starting from the current position of the buffer.
272         *                               After the operation, the position of the buffer is incremented by the number of bytes successfully sent.
273         *                               The new position cannot be larger than the original limit.
274         *                               This method can be used only for connection-oriented sockets.
275         *                               In the blocking mode, if space is not available in the send queue, the socket blocks until space becomes available.
276         *                               In the non-blocking mode, this method returns the error E_WOULD_BLOCK.
277         *                               This method may complete successfully even if it sends less than the number of bytes
278         *                               in the buffer. The application should keep track of the number of bytes sent
279         *                               and retry the operation until the application sends the bytes in the buffer.
280         *                               There is no guarantee that the data that is sent appears on the network immediately.
281         *                               To increase network efficiency, the underlying system may delay transmission until a significant amount
282         *                               of outgoing data is collected. The successful completion of this method means that the underlying
283         *                               system has had room to buffer the data for a network send.
284         *                               If it is important for the application to send every byte to the remote host immediately,
285         *                               use SetSockOpt() (with NET_SOCKET_TCP_NODELAY) of the type ::NetSocketOptName to enable no delay.
286         */
287         result Send(Tizen::Base::ByteBuffer& buffer);
288
289         /**
290         * Sends the data to a socket of the type NET_SOCKET_TYPE_STREAM.
291         *
292         * @since        2.0
293         *
294         * @return               An error code
295         * @param[in]    pBuffer                                         The pointer to the buffer containing the data to send
296         * @param[in]    length                                          The length of the data in the buffer
297         * @param[out]   sentLength                                      The length of the data that is sent successfully
298         * @exception    E_SUCCESS                                       The method is successful.
299         * @exception    E_INVALID_SOCKET                        The socket is invalid.
300         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
301         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
302         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
303         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
304         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
305         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
306         * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
307         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
308         * @exception    E_SYSTEM                                        A system error has occurred.
309         * @remarks              This method sends the data to the remote host specified in the Connect() or AcceptN() method.
310         *                               This method sends the data in the buffer of length @c length, starting from the current position of the buffer.
311         *                               This method can be used only for connection-oriented sockets.
312         *                               In the blocking mode, if space is not available in the send queue, the socket blocks until space becomes available.
313         *                               In the non-blocking mode, this method returns the error E_WOULD_BLOCK.
314         *                               This method may complete successfully even if it sends less than the number of bytes
315         *                               in the buffer. The application should keep track of the number of bytes sent
316         *                               and retry the operation until the application sends the bytes in the buffer.
317         *                               There is no guarantee that the data that is sent appears on the network immediately.
318         *                               To increase the network efficiency, the underlying system may delay the transmission until a significant amount
319         *                               of outgoing data is collected. The successful completion of this method means that the underlying
320         *                               system has had room to buffer the data for a network send.
321         *                               If it is important to send every byte to the remote host immediately,
322         *                               use SetSockOpt() (with NET_SOCKET_TCP_NODELAY) of the type ::NetSocketOptName to enable no delay.
323         */
324         result Send(void* pBuffer, int length, int& sentLength);
325
326         /**
327         * Sends the data to a socket of the type NET_SOCKET_TYPE_DATAGRAM.
328         *
329         * @if OSPCOMPAT
330         * @brief <i> [Compatibility] </i>
331         * @endif
332         * @since            2.0
333         * @if OSPCOMPAT
334         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
335     *                   For more information, see @ref SocketSendToPage1 "here".
336     * @endif
337         *
338         * @return                       An error code
339         * @param[in]            buffer                                          An instance of Tizen::Base::ByteBuffer containing the data to send
340         * @param[in]            remoteEndPoint                          An instance of NetEndPoint representing the destination for the data
341         * @exception            E_SUCCESS                                       The method is successful.
342         * @exception            E_INVALID_SOCKET                        The socket is invalid.
343         * @exception            E_INVALID_STATE                         The socket is not in a valid state.
344         * @exception            E_UNSUPPORTED_OPTION            The specified parameters are not supported.
345         * @exception            E_INVALID_ARG                           A specified input parameter is invalid.
346         * @exception            E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
347         * @exception            E_HOST_UNREACHABLE                      The network cannot be reached from this host at this time.
348         * @exception            E_OUT_OF_RANGE                          The message length has exceeded the maximum limit of the socket.
349         * @exception        E_OUT_OF_MEMORY                             The memory is insufficient.
350         * @exception            E_SYSTEM                                        A system error has occurred.
351         * @remarks              This method sends the data to the remote host specified by the @c remoteEndPoint parameter.
352         *                               This method sends the data in the @c buffer parameter, starting from the current position of the buffer.
353         *                               After the operation, the position of the buffer is incremented by the number of bytes successfully sent.
354         *                               The new position cannot be larger than the original limit.
355         *                               This method can be used only for connectionless sockets.
356         *                               In the blocking mode, if space is not available in the send queue, the socket blocks
357         *                               until space becomes available. If the socket is in the non-blocking mode,
358         *                               the error E_WOULD_BLOCK is returned.
359         */
360         result SendTo(Tizen::Base::ByteBuffer& buffer, const Tizen::Net::NetEndPoint& remoteEndPoint);
361
362         /**
363     * @page                     SocketSendToPage1        Compatibility for SendTo()
364     *
365     * @section          SocketSendToPage1IssueSection Issues
366     * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
367     * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
368     *
369     * @section      SocketSendToPage1ResolutionSection Resolutions
370     * The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
371     * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead E_SYSTEM.
372     */
373
374         /**
375         * Sends the data to a socket of the type NET_SOCKET_TYPE_DATAGRAM.
376         *
377         * @if OSPCOMPAT
378         * @brief <i> [Compatibility] </i>
379         * @endif
380         * @since            2.0
381         * @if OSPCOMPAT
382         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
383     *                   For more information, see @ref SocketSendToPage2 "here".
384     * @endif
385         *
386         * @return                       An error code
387         * @param[in]            pBuffer                                 The pointer to the buffer containing the data to send
388         * @param[in]            length                                  The length of the data in the buffer
389         * @param[in]            remoteEndPoint                  An instance of NetEndPoint representing the destination for the data
390         * @param[out]           sentLength                              The length of the data that is sent successfully
391         * @exception            E_SUCCESS                               The method is successful.
392         * @exception            E_INVALID_SOCKET                The socket is invalid.
393         * @exception            E_INVALID_STATE                 The socket is not in a valid state.
394         * @exception            E_UNSUPPORTED_OPTION    The specified parameters are not supported.
395         * @exception            E_INVALID_ARG                   A specified input parameter is invalid.
396         * @exception            E_WOULD_BLOCK                   A non-blocking socket operation cannot be completed immediately.
397         * @exception            E_HOST_UNREACHABLE              The network cannot be reached from this host at this time.
398         * @exception            E_OUT_OF_RANGE                  The message length has exceeded the maximum limit of the socket.
399         * @exception        E_OUT_OF_MEMORY                     The memory is insufficient.
400         * @exception            E_SYSTEM                                A system error has occurred.
401         * @remarks                      This method sends the data to the remote host specified by the @c remoteEndPoint parameter.
402         *                                       This method sends the data in the buffer. The length of the data is specified by @c length, starting from the current
403         *                                       position of the buffer.
404         *                                       This method can be used only for connectionless sockets.
405         *                                       In the blocking mode, if space is not available in the send queue, the socket blocks
406         *                                       until space becomes available. If the socket is in the non-blocking mode,
407         *                                       the error E_WOULD_BLOCK is returned.
408         */
409         result SendTo(void* pBuffer, int length, const Tizen::Net::NetEndPoint& remoteEndPoint, int& sentLength);
410
411         /**
412     * @page                     SocketSendToPage2        Compatibility for SendTo()
413     *
414     * @section          SocketSendToPage2IssueSection Issues
415     * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
416     * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
417     *
418     * @section      SocketSendToPage2ResolutionSection Resolutions
419     * The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
420     * -# If the application provides a loopback address in NetEndPoint, it returns @c E_SUCCESS instead of @c E_SYSTEM.
421     */
422
423         /**
424         * Receives the data from a socket of the type ::NET_SOCKET_TYPE_STREAM.
425         *
426         * @since        2.0
427         *
428         * @return               An error code
429         * @param[out]   buffer                                          An instance of Tizen::Base::ByteBuffer that is the storage location for the received data
430         * @exception    E_SUCCESS                                       The method is successful.
431         * @exception    E_INVALID_SOCKET                        The socket is invalid.
432         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
433         * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
434         * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
435         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
436         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
437         * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
438         * @exception    E_IN_PROGRESS                           A previous request is in progress.
439         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
440         * @exception    E_SYSTEM                                        A system error has occurred.
441         * @remarks              This method copies the data into the @c buffer parameter, starting from the current position of the buffer.
442         *                               After the operation, the position of the buffer is incremented by the number of bytes successfully received.
443         *                               The new position cannot be larger than the original limit.
444         *                               This method can only be called from connection-oriented sockets.
445         *                               If there is no data at the socket in the blocking mode,
446         *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
447         *                               the error E_WOULD_BLOCK is returned.
448         */
449         result Receive(Tizen::Base::ByteBuffer& buffer) const;
450
451         /**
452         * Receives the data from a socket of the type ::NET_SOCKET_TYPE_STREAM.
453         *
454         * @since        2.0
455         *
456         * @return               An error code
457         * @param[out]   pBuffer                                         The pointer to the buffer that is the storage location for the received data
458         * @param[in]    length                                          The length of the data in the buffer
459         * @param[out]   rcvdLength                                      The length of the data that is received successfully
460         * @exception    E_SUCCESS                                       The method is successful.
461         * @exception    E_INVALID_SOCKET                        The socket is invalid.
462         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
463         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
464         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
465         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
466         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
467         * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
468         * @exception    E_IN_PROGRESS                           A previous request is in progress.
469         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
470         * @exception    E_SYSTEM                                        A system error has occurred.
471         * @remarks              This method copies the data into the buffer. The length of the data is specified by @c length, starting from the current
472         *                               position of the buffer.
473         *                               This method can be called only from connection-oriented sockets.
474         *                               If there is no data at the socket in the blocking mode,
475         *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
476         *                               the error E_WOULD_BLOCK is returned.
477         */
478         result Receive(void* pBuffer, int length, int& rcvdLength) const;
479
480         /**
481         * Receives the data from a socket of the type NET_SOCKET_TYPE_DATAGRAM.
482         *
483         * @if OSPCOMPAT
484         * @brief <i> [Compatibility] </i>
485         * @endif
486         * @since        2.0
487         * @if OSPCOMPAT
488         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
489     *                   For more information, see @ref SocketReceiveFromPage1 "here".
490     * @endif
491         *
492         * @return               An error code
493         * @param[out]   buffer                                          An instance of Tizen::Base::ByteBuffer that is the storage location for the received data
494         * @param[out]   remoteEndPoint                          The NetEndPoint of the remote server
495         * @exception    E_SUCCESS                                       The method is successful.
496         * @exception    E_INVALID_SOCKET                        The socket is invalid.
497         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
498         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
499         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
500         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
501         * @exception    E_IN_PROGRESS                           A previous request is in progress.
502         * @exception    E_OUT_OF_RANGE                          The message length exceeded the maximum limit.
503         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
504         * @exception    E_SYSTEM                                        A system error has occurred.
505         * @remarks              This method copies the data into the specified buffer, starting from the current position of the buffer.
506         *                               After the operation, the position of the buffer is incremented by the number of bytes successfully received.
507         *                               The new position cannot be larger than the original limit.
508         *                               The method returns the remote host endpoint from which the data is sent.
509         *                               This method can only be called from connectionless sockets; that is,
510         *                               this method is used only if connectionless datagrams are to be received
511         *                               from an unknown host or multiple hosts.
512         *                               This method reads the first enqueued datagram received
513         *                               into the local network buffer. If the datagram received is larger
514         *                               than the remaining bytes of the buffer, this method returns the error E_OUT_OF_RANGE.
515         *                               If there is no data at the socket in the blocking mode,
516         *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
517         *                               the error E_WOULD_BLOCK is returned.
518         */
519         result ReceiveFrom(Tizen::Base::ByteBuffer& buffer, Tizen::Net::NetEndPoint& remoteEndPoint) const;
520
521         /**
522     * @page                     SocketReceiveFromPage1  Compatibility for ReceiveFrom()
523     *
524     * @section          SocketReceiveFromPage1IssueSection Issues
525     * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
526     * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
527     *
528     * @section          SocketReceiveFromPage1ResolutionSection Resolutions
529     * The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
530     * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
531     */
532
533         /**
534         * Receives the data from a socket of the type NET_SOCKET_TYPE_DATAGRAM.
535         *
536         * @if OSPCOMPAT
537         * @brief <i> [Compatibility] </i>
538         * @endif
539         * @since        2.0
540         * @if OSPCOMPAT
541         * @compatibility        This method has compatibility issues with OSP compatible applications. @n
542     *                   For more information, see @ref SocketReceiveFromPage2 "here".
543     * @endif
544         *
545         * @return               An error code
546         * @param[out]   pBuffer                                         The pointer to the buffer that is the storage location for the received data
547         * @param[in]    length                                          The length of the data in the buffer
548         * @param[out]   remoteEndPoint                          The NetEndPoint of the remote server
549         * @param[out]   rcvdLength                                      The length of the data that is received successfully
550         * @exception    E_SUCCESS                                       The method is successful.
551         * @exception    E_INVALID_SOCKET                        The socket is invalid.
552         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
553         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
554         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
555         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
556         * @exception    E_IN_PROGRESS                           A previous request is in progress.
557         * @exception    E_OUT_OF_RANGE                          The message length exceeded the maximum limit.
558         * @exception  E_OUT_OF_MEMORY                           The memory is insufficient.
559         * @exception    E_SYSTEM                                        A system error has occurred.
560         * @remarks              This method copies the data into the buffer. The length of the data is specified by @c length, starting from the current
561         *                               position of the buffer.
562         *                               The method returns the remote host endpoint from which the data is sent.
563         *                               This method can only be called from connectionless sockets; that is,
564         *                               this method is used only if connectionless datagrams are to be received
565         *                               from an unknown host or multiple hosts.
566         *                               This method reads the first enqueued datagram received
567         *                               into the local network buffer. If the datagram received is larger
568         *                               than the value of @c length parameter, this method will return an error E_OUT_OF_RANGE.
569         *                               If there is no data at the socket in the blocking mode,
570         *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
571         *                               the error E_WOULD_BLOCK is returned.
572         */
573         result ReceiveFrom(void* pBuffer, int length, Tizen::Net::NetEndPoint& remoteEndPoint, int& rcvdLength) const;
574
575         /**
576     * @page                     SocketReceiveFromPage2  Compatibility for ReceiveFrom()
577     *
578     * @section          SocketReceiveFromPage2IssueSection Issues
579     * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
580     * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
581     *
582     * @section          SocketReceiveFromPage2ResolutionSection Resolutions
583     * The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
584     * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
585     */
586
587         /**
588         * Binds the socket to a local address.
589         *
590         * @since                        2.0
591         * @privlevel            public
592         * @privilege            %http://tizen.org/privilege/socket
593         *
594         * @return               An error code
595         * @param[in]    localEndPoint                           The local NetEndPoint to associate with the socket
596         * @exception    E_SUCCESS                                       The method is successful.
597         * @exception    E_INVALID_SOCKET                        The socket is invalid.
598         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
599         * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
600         * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
601         * @exception    E_ALREADY_BOUND                         The address is already in use.
602         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
603         * @exception    E_SYSTEM                                        A system error has occurred.
604         * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
605         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
606         * @remarks              Use this method if a specific local endpoint should be used.
607         *                               This method can be used on both the connectionless and connection-oriented protocols.
608         *                               For connection-oriented sockets, this method need not be called
609         *                               before using the Connect() method, unless a specific local endpoint needs to be used.
610         *                               This method must be called before the Listen() method.
611         */
612         result Bind(const Tizen::Net::NetEndPoint& localEndPoint);
613
614         /**
615         * Places the socket in a listening state.
616         *
617         * @since                        2.0
618         * @privlevel            public
619         * @privilege            %http://tizen.org/privilege/socket
620         *
621         * @return               An error code
622         * @param[in]    backLog                                         The maximum length of the pending connections queue
623         * @exception    E_SUCCESS                                       The method is successful.
624         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
625         * @exception    E_INVALID_SOCKET                        The socket is invalid.
626         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
627         * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
628         * @exception    E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
629         * @exception    E_ALREADY_CONNECTED                     The socket is already connected.
630         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
631         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
632         * @exception    E_SYSTEM                                        A system error has occurred.
633         * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
634         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
635         * @remarks              This method causes a connection-oriented socket to listen for
636         *                               the incoming connection attempts. The @c backlog parameter specifies
637         *                               the number of incoming connections that can be queued for acceptance.
638         *                               The Bind() method must be called before calling this method.
639         */
640         result Listen(int backLog);
641
642         /**
643         * Accepts an incoming connection. @n
644         * This method extracts the first connection from the queue of pending connections, and
645         * creates a new socket with the same socket type, protocol type, and protocol family
646         * as the listening socket.
647         *
648         * @since                        2.0
649         * @privlevel            public
650         * @privilege            %http://tizen.org/privilege/socket
651         *
652         * @return               A new socket for a newly created connection with the same socket type, protocol type, and protocol family, @n
653         *                               else @c null if an error occurs
654         * @exception    E_SUCCESS                                       The method is successful.
655         * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
656         * @exception    E_INVALID_SOCKET                        The socket is invalid.
657         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
658         * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
659         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
660         * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
661         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
662         * @exception    E_SYSTEM                                        A system error has occurred.
663         * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
664         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
665         * @remarks              Before calling this method, the Listen() method must be called first
666         *                               to listen for and queue the incoming connection requests.
667         *                               In the blocking mode, this method blocks until an incoming connection attempt
668         *                               is queued. After accepting a connection, the original socket
669         *                               continues queuing the incoming connection requests until it is closed.
670         *                               Note that if no connection is pending in the queue and the socket is in the blocking mode,
671         *                               this method blocks until a new connection arrives. If the socket is in the non-blocking mode,
672         *                               the E_WOULD_BLOCK exception is thrown. The specific error code can be accessed using the GetLastResult() method.
673         */
674         Socket* AcceptN(void) const;
675
676         /**
677         * Executes the specified command on the socket.
678         *
679         * @since                        2.0
680         * @privlevel            public
681         * @privilege            %http://tizen.org/privilege/socket
682         *
683         * @return               An error code
684         * @param[in]    cmd                                 The command to execute on the socket
685         * @param[in,out] value                                          The value of the IOCTL command
686         * @exception    E_SUCCESS                                       The method is successful.
687         * @exception    E_INVALID_SOCKET                        The socket is invalid.
688         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
689         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
690         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
691         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
692         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
693         * @exception    E_SYSTEM                                        A system error has occurred.
694         * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
695         * @exception    E_USER_NOT_CONSENTED            The user blocks an application from calling this method. @b Since: @b 2.1
696         * @remarks              This method manipulates the underlying device parameters of the socket descriptors. @n@n
697         *                               The NET_SOCKET_FIONBIO option is used for setting the non-blocking/blocking mode on a socket.
698         *                               Set the value to zero for enabling the blocking mode, or to a non-zero value for enabling the non-blocking mode.
699         *                               When a socket is created, by default, it operates in the non-blocking mode and the blocking mode is disabled. @n
700         *                               The NET_SOCKET_FIONREAD option is used for getting the number of bytes that are immediately available for reading. @n
701         *                               The NET_SOCKET_FIONWRITE option is used for getting the number of bytes that have not yet been
702         *                       acknowledged by the other side of the connection. This option is not supported in this SDK. @n
703         *                               The NET_SOCKET_SIOCATMARK option is used to determine if all out of band (OOB) data has been read.
704         *                               Currently sockets do not support this option.
705         *
706         */
707         result Ioctl(NetSocketIoctlCmd cmd, unsigned long& value) const;
708
709         /**
710         * Sets the socket to the asynchronous mode by a specified message to the specified event handler when the socket events occur.
711         *
712         * @since        2.0
713         *
714         * @return               An error code
715         * @param[in]    socketEventType                         The socket events of ::NetSocketEventType @n
716         *                                                                                       Multiple events can be combined using the bitwise "|" operator.
717         * @exception    E_SUCCESS                                       The method is successful.
718         * @exception    E_INVALID_SOCKET                        The socket is invalid.
719         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
720         * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
721         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
722         * @exception    E_TIMEOUT                   An attempt to connect to the server has timed out.
723         *
724         */
725         result AsyncSelectByListener(unsigned long socketEventType);
726
727         /**
728         * Adds the specified listener to the socket.
729         *
730         * @since        2.0
731         *
732         * @return               An error code
733         * @param[in]    listener                                A reference to ISocketEventListener
734         * @exception    E_SUCCESS                               The method is successful.
735         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
736         * @exception    E_INVALID_SOCKET                The socket is invalid.
737         * @exception    E_INVALID_STATE                 The associated socket is not in a valid state.
738         * @exception    E_SYSTEM                                A system error has occurred.
739         * @exception    E_OBJ_ALREADY_EXIST             The listener is already added.
740         * @exception    E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
741         *                                                                               because the caller thread is a worker thread.
742         */
743         result AddSocketListener(ISocketEventListener& listener);
744
745         /**
746         * Removes the specified listener.
747         *
748         * @since        2.0
749         *
750         * @return       An error code
751         * @param[in]    listener                                A reference to ISocketEventListener
752         * @exception    E_SUCCESS                               The method is successful.
753         * @exception    E_OBJ_NOT_FOUND                 The specified object is not found within the indicated range.
754         * @exception    E_INVALID_SOCKET                The socket is invalid.
755         * @exception    E_INVALID_STATE                 The associated socket is not in a valid state.
756         * @exception    E_SYSTEM                                A system error has occurred.
757         */
758         result RemoveSocketListener(ISocketEventListener& listener);
759
760         /**
761         * Gets the peer endpoint for this socket. @n
762         * It returns a NetEndPoint containing the peer IP address and port number.
763         *
764         * @since        2.0
765         *
766         * @return               The peer endpoint for the calling %Socket instance, @n
767         *                               else @c null if the socket is not connected to any peer
768         * @exception    E_SUCCESS                       The method is successful.
769         * @exception    E_INVALID_STATE         The socket is not in a valid state.
770         * @exception    E_SYSTEM                        A system error has occurred.
771         * @remarks              The specific error code can be accessed using the GetLastResult() method.
772         * @see                  GetLocalEndPoint()
773         */
774         const NetEndPoint* GetPeerEndPoint(void);
775
776         /**
777         * Gets the local endpoint for this socket. @n
778         * It returns a NetEndPoint containing the local IP address and port number.
779         *
780         * @since        2.0
781         *
782         * @return               The local endpoint for the calling %Socket instance, @n
783         *                               else @c null
784         * @exception    E_SUCCESS                       The method is successful.
785         * @exception    E_INVALID_STATE         The socket is not in a valid state.
786         * @exception    E_SYSTEM                        A system error has occurred.
787         * @remarks              The specific error code can be accessed using the GetLastResult() method.
788         * @remarks              This NetEndPoint must be cast to a %NetEndPoint before retrieving any information.
789         */
790         const NetEndPoint* GetLocalEndPoint(void);
791
792         /**
793         * Gets an option of the socket.
794         *
795         * @since        2.0
796         *
797         * @return               An error code
798         * @param[in]    optionLevel                                     A ::NetSocketOptLevel value
799         * @param[in]    optionName                                      A ::NetSocketOptName value
800         * @param[out]   optionValue                                     The integer to receive the option setting
801         * @exception    E_SUCCESS                                       The method is successful.
802         * @exception    E_INVALID_SOCKET                        The socket is invalid.
803         * @exception    E_INIT_FAILED                           The socket is not initialized.
804         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
805         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
806         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
807         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
808         * @exception    E_IN_PROGRESS                           A previous request is in progress.
809         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
810         * @exception    E_SYSTEM                                        A system error has occurred.
811         * @remarks              The socket options determine the behavior of the current socket.
812         *                               Upon successful completion of this method,
813         *                               @c optionValue parameter contains the value of the specified socket option.
814         *                               For an option with a bool data type, a non-zero value is returned if the option is enabled. Otherwise,
815         *                               a zero value is returned. For an option with an integer data type, the method returns the appropriate value.
816         *                               The socket options are grouped by the level of protocol support. @n@n
817         *                               Listed below are the various socket options that can be obtained using this overload. These options are
818         *                               grouped by the appropriate NetSocketOptLevel.
819         *                               Use the appropriate %NetSocketOptLevel for the @c optionLevel parameter. The option that is chosen,
820         *                               must be specified in the @c optionName parameter. To set the current value of some of
821         *                               the listed options, use the SetSockOpt() method. @n@n
822         *                               The OptionNames are categorized under their specific option levels. @n@n
823         *                               NET_SOCKET_IPPROTO_TCP  @n
824         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_NODELAY: Disables the Nagle algorithm for send coalescing. @n
825         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_MAXSEG: Specifies the MSS(Maximum Segment Size) for TCP. @n@n
826         *                               NET_SOCKET_IPPROTO_IP @n
827         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TTL: Time-to-live. @n
828         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TOS: Type-of-service and precedence. @n@n
829         *                               NET_SOCKET_SOL_SOCKET @n
830         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_ACCEPTCONN: The socket is listening. @n
831         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_BROADCAST: Permits the sending of broadcast messages. @n
832         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_DONTROUTE : Do not route. Send the packet directly to the interface addresses. @n
833         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_ERROR : For getting pending error and clear. @n
834         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_KEEPALIVE: Uses keep-alive. @n
835         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_LINGER: Lingers on close if data is present. @n
836         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_OOBINLINE: Leaves the received Out Of Band data in line. @n
837         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVBUF: Buffer size for receives. @n
838         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVTIMEO: Receives a time-out. @n
839         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_REUSEADDR: Allows the socket to be bound to an address that is already in use. @n
840         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDBUF: Buffer size for sends. @n
841         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDTIMEO: Sends a time-out. @n
842         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_TYPE: Gets the socket type. @n
843         * @see SetSockOpt()
844         */
845         result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const;
846
847         /**
848         * Gets the socket option status of SO_LINGER.
849         *
850         * @since        2.0
851         *
852         * @return               An error code
853         * @param[in]    optionLevel                                     The socket option level @n
854         *                                                                                       The @c optionLevel is NET_SOCKET_SOL_SOCKET.
855         * @param[in]    optionName                                      The socket configuration option name @n
856         *                                                                                       The @c optionName is NET_SOCKET_SO_LINGER.
857         * @param[out]   optionValue                                     The instance of LingerOption that is to receive the option setting
858         * @exception    E_SUCCESS                                       The method is successful.
859         * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
860         * @exception    E_INVALID_SOCKET                        The socket is invalid.
861         * @exception    E_INIT_FAILED                           The socket is not initialized.
862         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
863         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
864         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
865         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
866         * @exception    E_IN_PROGRESS                           A previous request is in progress.
867         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
868         * @exception    E_SYSTEM                                        A system error has occurred.
869         * @see Tizen::Net::Sockets::LingerOption
870         */
871         result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, LingerOption& optionValue) const;
872
873         /**
874         * Changes an option of the socket.
875         *
876         * @since        2.0
877         *
878         * @return               An error code
879         * @param[in]    optionLevel                                     A ::NetSocketOptLevel value
880         * @param[in]    optionName                                      A ::NetSocketOptName value
881         * @param[in]    optionValue                                     The option value
882         * @exception    E_SUCCESS                                       The method is successful.
883         * @exception    E_INVALID_SOCKET                        The socket is invalid.
884         * @exception    E_INIT_FAILED                           The socket is not initialized.
885         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
886         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
887         * @exception    E_INVALID_STATE                         The socket is not in a valid state.
888         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
889         * @exception    E_IN_PROGRESS                           A previous request is in progress.
890         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
891         * @exception    E_SYSTEM                                        A system error has occurred.
892         * @remarks              This method is used to change the value of the option specified by the @c optionName parameter.
893         *                               The socket options determine the behavior of the current socket. For an option with a bool data type,
894         *                               specify a non-zero value to enable the option, and a zero value to disable the option.
895         *                               For an option with an integer data type, specify the appropriate value. The socket options are grouped
896         *                               by the level of protocol support. @n@n
897         *                               Listed below are the various socket options that can be set using this overload. These options are
898         *                               grouped by the appropriate NetSocketOptLevel. If any of these options are to be set,
899         *                               use the appropriate %NetSocketOptLevel for the @c optionLevel parameter. The chosen option
900         *                               must be specified in the @c optionName parameter. To get the current value of some of
901         *                               the options listed, use the GetSockOpt() method. @n@n
902         *                               The OptionNames are categorized under their specific option levels. @n@n
903         *                               NET_SOCKET_IPPROTO_TCP @n
904         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_NODELAY: Disables the Nagle algorithm for send coalescing. @n
905         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_MAXSEG: Specifies the MSS(Maximum Segment Size) for TCP. @n@n
906         *                               NET_SOCKET_IPPROTO_IP @n
907         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TTL: Time-to-live. @n
908         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TOS: Type-of-service and precedence. @n@n
909         *                               NET_SOCKET_SOL_SOCKET @n
910         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_BROADCAST : Permits the sending of broadcast messages. @n
911         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_DONTROUTE : Do not route. Send the packet directly to the interface addresses. @n
912         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_KEEPALIVE: Uses keep-alive. @n
913         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_LINGER: Lingers on close if data is present. @n
914         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_OOBINLINE: Leaves the received Out Of Band data in line. @n
915         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVBUF: Buffer size for receives. @n
916         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVTIMEO: Receives a time-out. @n
917         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_REUSEADDR: Allows the socket to be bound to an address that is already in use. @n
918         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDBUF: Buffer size for sends. @n
919         *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDTIMEO: Sends a time-out.
920         *
921         *
922         */
923         result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue);
924
925         /**
926         * Enables or disables SO_LINGER with the specified linger time in seconds. @n
927         * The maximum timeout value is platform-specific. This setting only affects socket close.
928         *
929         * @since        2.0
930         *
931         * @return               An error code
932         * @param[in]    optionLevel                                     The socket option level @n
933         *                                                                                       The @c optionLevel is NET_SOCKET_SOL_SOCKET.
934         * @param[in]    optionName                                      The socket configuration option name @n
935         *                                                                                       The @c optionName is NET_SOCKET_SO_LINGER.
936         * @param[in]    optionValue                                     An instance of LingerOption that holds the option setting
937         * @exception    E_SUCCESS                                       The method is successful.
938         * @exception    E_INVALID_SOCKET                        The socket is invalid.
939         * @exception    E_INIT_FAILED                           The socket is not initialized.
940         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
941         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
942         * @exception    E_INVALID_STATE                         The socket is in an invalid state.
943         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
944         * @exception    E_IN_PROGRESS                           A previous request is in progress.
945         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
946         * @exception    E_SYSTEM                                        A system error has occurred.
947         *
948         */
949         result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const LingerOption& optionValue);
950
951         /**
952         * Enables the adding or dropping of a membership for the specified multicast group. @n
953         * Multicast datagram packets are transmitted only to the multicast group members. @n
954         * A socket must join a multicast group before the data is received. @n
955         * Do not call NET_SOCKET_SO_IP_ADD_MEMBERSHIP with the same group more than once on the same network interface.
956         *
957         * @since        2.0
958         *
959         * @return               An error code
960         * @param[in]    optionLevel                                     Set to @c NET_SOCKET_IPPROTO_IP
961         * @param[in]    optionName                                      Set to either @c NET_SOCKET_IP_ADD_MEMBERSHIP or @c NET_SOCKET_IP_DROP_MEMBERSHIP only
962         * @param[in]    optionValue                                     An instance of IpMulticastRequestOption that contains the network interface and group address for multicasting
963         * @exception    E_SUCCESS                                       The method is successful.
964         * @exception    E_INVALID_SOCKET                        The socket is invalid.
965         * @exception    E_INIT_FAILED                           The socket is not initialized.
966         * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
967         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
968         * @exception    E_INVALID_STATE                         The socket is in an invalid state.
969         * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
970         * @exception    E_IN_PROGRESS                           A previous request is in progress.
971         * @exception    E_CONNECTION_FAILED                     The socket is not connected.
972         * @exception    E_SYSTEM                                        A system error has occurred.
973         *
974         */
975         result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const IpMulticastRequestOption& optionValue);
976
977 private:
978         /**
979         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
980         *
981         * @param[in]    rhs             An instance of %Socket
982         */
983         Socket(const Socket& rhs);
984
985         /**
986         * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
987         *
988         * @return               A reference to this instance
989         * @param[in]    rhs                     An instance of %Socket
990         */
991         Socket& operator =(const Socket& rhs);
992
993 private:
994         _SocketImpl* __pSocketImpl;
995
996         friend class _SocketImpl;
997 };
998
999 } } }   // Tizen::Net::Sockets
1000 #endif // _FNET_SOCK_SOCKET_H_