当前位置: 代码迷 >> Symbian >> Symbian套接字
  详细解决方案

Symbian套接字

热度:3560   发布时间:2013-02-26 00:00:00.0
Symbian套接字求助
void CTestConnectionAppUi::TCPSendReceiveL()
{
//open socket server sessioin
RSocketServ ss;
CleanupClosePushL(ss);
TInt err = ss.Connect();
User::LeaveIfError(err);
//Open connnection on the socket server session
RConnection conn;
CleanupClosePushL(conn);
User::LeaveIfError(conn.Open(ss));
//start the default connection
TRequestStatus status;
conn.Start(status);
//wait for the connection to start
User::WaitForRequest(status);
//Check if start succeed
User::LeaveIfError(status.Int());
//open TCP socket on the started connection
RSocket sock;
CleanupClosePushL(sock);
TInt error;
error = sock.Open(ss,KAfInet,KSockStream,KProtocolInetTcp,conn);
User::LeaveIfError(error);
//Connection to the remote peer(symbian.com)
TInetAddr remoteAddr(INET_ADDR(81,89,143,203), 80);
sock.Connect(remoteAddr,status);
User::WaitForRequest(status);
User::LeaveIfError(status.Int());

/*Now that we are connected,
 * exchange some data...
 * Make a HTTP GET request to the remote peer   
 */
_LIT8(KHTTPGetRequest,"Hello");
sock.Write(KHTTPGetRequest(),status);
User::WaitForRequest(status);

}
这是我找到的一个用TCP套接字发送数据的简单方法, 但是运行后回会出现系统错误 -34的提示..请问该如何解决..谢谢了。
------解决方案--------------------------------------------------------
问题找到了