A Listener opens and prepares the sockets to listen for incoming socket connection requests at the TCP layer. This section describes how to implement a Listener.
Create RCONNECTION().
Create a session with the socket server:
RSocketServ::Connect;
Open a TCP socket on the new session:
RSocket::Open(iSS, KAfInet, KSockStream, KProtocolInetTcp,iSubconn);
Optionally, to open a new connection over a session, perform the following steps:
Create a new session with the socket server:
RSocketServ::Connect();
Open a new connection over the session:
RCONNECTION::Open(iSS);
Modify the commsDB settings:
TCommDbConnPref prefs; prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
Start the connection:
RCONNECTION::Start(prefs);
Open the default sub-connection over the new connection:
RSubConnection::Open(iSS, RSubConnection::EAttachToDefault, iConn);
Open a TCP socket on the sub-connection:
RSocket::Open(iSS, KAfInet, KSockStream, KProtocolInetTcp,iSubconn);
The socket type must be Stream Socket.
Wait and accept new connection.
Acquire the socket.
To get a new blank socket, use NewSocketL(), This method returns a reference to the new blank socket.
RSocket& socket(MPTPIPController&::NewSocketL());
Note: There is a limit to the number of sockets returned in each session.
You must then call the Accept() API using the blank socket to accept and bind the remote connection request with the given socket.
RSocket::Accept(socket, iStatus);
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.