2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
20 * @file FNetSockSocketUtility.h
21 * @brief This is the header file for the %SocketUtility class.
23 * This header file contains the declarations of the %SocketUtility class. @n
24 * This class provides utility methods for socket operations.
27 #ifndef _FNET_SOCK_SOCKET_UTILITY_H_
28 #define _FNET_SOCK_SOCKET_UTILITY_H_
32 namespace Tizen { namespace Net { namespace Sockets
35 class _SocketUtilityImpl;
38 * @class SocketUtility
39 * @brief This class provides the utility methods for the Socket class.
43 * The %SocketUtility class provides the utility methods for the Socket class.
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
47 class _OSP_EXPORT_ SocketUtility
48 : public Tizen::Base::Object
53 * 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 * This destructor overrides Tizen::Base::Object::~Object().
64 virtual ~SocketUtility(void);
67 * Initializes this instance of %SocketUtility.
71 * @return An error code
72 * @exception E_SUCCESS The method is successful.
73 * @exception E_INVALID_STATE This instance is in an invalid state.
74 * @exception E_OUT_OF_MEMORY The memory is insufficient.
75 * @exception E_SYSTEM Interface creation has failed.
77 result Construct(void);
80 * Determines the status of one or more sockets.
84 * @privilege http://tizen.org/privilege/socket
86 * @return An error code
87 * @param[in,out] pCheckRead An IList of Socket instances to check for readability
88 * @param[in,out] pCheckWrite An IList of Socket instances to check for writability
89 * @param[in,out] pCheckError An IList of Socket instances to check for errors
90 * @param[in] microSeconds The time to wait for a response, in microseconds
91 * @exception E_SUCCESS The method is successful.
92 * @exception E_INVALID_SOCKET The socket is invalid.
93 * @exception E_INVALID_STATE The socket is in an invalid state.
94 * @exception E_UNSUPPORTED_OPTION The specified parameters are not supported.
95 * @exception E_INVALID_ARG A specified input parameter is invalid.
96 * @exception E_TIMEOUT The time limit has expired.
97 * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
98 * @exception E_OUT_OF_MEMORY The memory is insufficient.
99 * @exception E_SYSTEM A system error has occurred.
100 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
101 * @remarks This method determines the status of one or more
102 * Socket instances. There must be at least one socket in an IList
103 * before this method is used.
104 * To check sockets for readability and writability use @c pCheckRead and @c pCheckWrite of type
105 * %IList respectively by calling this method.
106 * To detect error conditions, use @c pCheckError.
107 * After calling this method, the %IList is filled with only those sockets that satisfy the conditions. @n
108 * All the receive operations succeed without blocking in the following cases: @n
109 * -# If the socket is in a listening state, the readability means that a call to Accept() succeeds without blocking.
110 * -# If the connection on a socket is accepted, the readability means that the data is available for reading. @n
111 * The readability can also indicate whether the remote socket has shutdown the connection. In this
112 * case a call to SecureSocket::Receive() or Socket::Receive() returns immediately with @c 0 bytes.
113 * If a non-blocking call to SecureSocket::Connect() or Socket::Connect() is made, the writability means that the connection is
114 * successful and the @c pCheckError parameter identifies the sockets that are not
115 * connected successfully. @n
116 * If a connection has already been established, the writability means that all the send operations
117 * have succeeded without blocking.
119 result Select(Tizen::Base::Collection::IList* pCheckRead, Tizen::Base::Collection::IList* pCheckWrite, Tizen::Base::Collection::IList* pCheckError, int microSeconds);
122 * Converts the specified unsigned @c short integer from a host @c byte order to a network @c byte order.
126 * @return An unsigned @c short integer in network @c byte order
127 * @param[in] hostShort An unsigned @c short integer in host @c byte order
128 * @remarks The specific error code can be accessed using the GetLastResult() method.
131 unsigned short HtoNS(unsigned short hostShort);
134 * Converts the specified unsigned @c long integer from a host @c byte order to a network @c byte order.
138 * @return An unsigned @c long integer in network @c byte order
139 * @param[in] hostLong An unsigned @c long integer in host @c byte order
140 * @remarks The specific error code can be accessed using the GetLastResult() method.
143 unsigned long HtoNL(unsigned long hostLong);
146 * Converts the specified unsigned @c short integer from a network @c byte order to a host @c byte order.
150 * @return An unsigned @c short integer in host @c byte order
151 * @param[in] netShort An unsigned @c short integer in network @c byte order
152 * @remarks The specific error code can be accessed using the GetLastResult() method.
155 unsigned short NtoHS(unsigned short netShort);
158 * Converts the specified unsigned @c long integer from a network @c byte order to a host @c byte order.
162 * @return An unsigned @c long integer in host @c byte order
163 * @param[in] netLong An unsigned @c long integer in network @c byte order
164 * @remarks The specific error code can be accessed using the GetLastResult() method.
167 unsigned long NtoHL(unsigned long netLong);
171 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
173 * @param[in] rhs An instance of %SocketUtility
175 SocketUtility(const SocketUtility& rhs);
178 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
180 * @return A reference to this instance
181 * @param[in] rhs An instance of %SocketUtility
183 SocketUtility& operator =(const SocketUtility& rhs);
186 _SocketUtilityImpl* __pSocketUtilityImpl;
188 friend class _SocketUtilityImpl;
191 } } } // Tizen::Net::Sockets
192 #endif // _FNET_SOCK_SOCKET_UTILITY_H_