2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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 FNetSockISocketEventListener.h
21 * @brief This is the header file for the %ISocketEventListener interface.
23 * This header file contains the declarations of the %ISocketEventListener interface.
26 #ifndef _FNET_SOCK_ISOCKET_EVENT_LISTENER_H_
27 #define _FNET_SOCK_ISOCKET_EVENT_LISTENER_H_
29 #include <FBaseRtIEventListener.h>
30 #include <FNetSockSocketTypes.h>
32 namespace Tizen { namespace Net { namespace Sockets
38 * @interface ISocketEventListener
39 * @brief This interface contains a listener for the socket events.
43 * The %ISocketEventListener interface specifies methods used for creating notifications about the different kinds of socket events.
44 * These events are only sent out when using the socket in a non-blocking mode. A listener is registered by calling the AddSocketListener()
45 * method. One of these methods is called when a socket event is generated.
47 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
49 * The following example demonstrates how to use the %ISocketEventListener interface.
52 using namespace Tizen::Net::Sockets;
56 , public virtual ISocketEventListener
63 void OnSocketConnected(Socket& socket)
65 AppLog("OnConnected\n");
68 void OnSocketClosed(Socket& socket, NetSocketClosedReason reason)
73 void OnSocketReadyToReceive(Socket& socket)
75 AppLog("OnReadyToReceive\n");
78 void OnSocketReadyToSend(Socket& socket)
80 AppLog("OnReadyToSend\n");
85 class _OSP_EXPORT_ ISocketEventListener
86 : virtual public Tizen::Base::Runtime::IEventListener
92 * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
96 virtual ~ISocketEventListener(void) {}
101 * Called to notify a connecting socket that its connection attempt has been completed successfully.
105 * @param[in] socket The Socket instance
107 virtual void OnSocketConnected(Socket& socket) = 0;
110 * Called to notify the registered socket that the peer socket has been closed due to normal or forced termination of the network. @n
111 * It is also used to notify a connecting socket that its connection attempt has resulted in an error.
115 * @param[in] socket The Socket instance
116 * @param[in] reason The reason of type NetSocketClosedReason for a closed socket
118 virtual void OnSocketClosed(Socket& socket, NetSocketClosedReason reason) = 0;
121 * Called to notify a socket that the data is ready to be retrieved.
125 * @param[in] socket The Socket instance
126 * @remarks The data can be retrieved by calling Receive() or ReceiveFrom().
128 virtual void OnSocketReadyToReceive(Socket& socket) = 0;
131 * Called to notify a socket that the data can be sent.
135 * @param[in] socket The Socket instance
136 * @remarks The data can be sent using Send() or SendTo().
138 virtual void OnSocketReadyToSend(Socket& socket) = 0;
141 * Called to notify a socket that it has received a new connection from a peer.
145 * @param[in] socket The Socket instance
147 virtual void OnSocketAccept(Socket& socket) = 0;
151 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
153 // This method is reserved and may change its name at any time without prior notice.
157 virtual void ISocketEventListener_Reserved1(void) {}
160 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
162 // This method is reserved and may change its name at any time without prior notice.
166 virtual void ISocketEventListener_Reserved2(void) {}
170 } } } // Tizen::Net::Sockets
171 #endif // _FNET_SOCK_ISOCKET_EVENT_LISTENER_H_