This topic describes how to use secure sockets.
In the following example iSocket is a reference to the already opened and connected socket and KSSLProtocol is the descriptor containing the name of a protocol, in this case TLS1.0. The function should return a pointer to the CSecureSocket.
// Connect the socket server User::LeaveIfError(iSocketServ.Connect()); // Open the socket User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp)); //Connect the socket connectInetAddr.SetAddress(KTestAddress); connectInetAddr.SetPort(KSSLPort); //TLS port iSocket.Connect(connectInetAddr, iStatus); ... // Construct the Tls socket iTlsSocket = CSecureSocket::NewL(iSocket, KSSLProtocol()); // start the handshake iTlsSocket->StartClientHandshake(iStatus);
Use CSecureSocket::Send() to send data over the socket. Use CSecureSocket::Recv() and CSecureSocket::RecvOneOrMore() to receive data from the socket.
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.