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