专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Symbian

关于symbian通过socket发生结构体 有代码解决方案

发布时间:2010-05-30 00:33:16 文章来源:www.iduyao.cn 采编人员:星星草
关于symbian通过socket发生结构体 有代码
void CTestConnectionAppUi::TCPSendReceiveL()
{
//define the struct which to send
_LIT8(KHTTPGetRequest,"Hello");
Info *iInfo = new Info();


iInfo->bWorkNetName=KHTTPGetRequest;
iInfo->iWorkData = 20;
TPtr8 iBufferPtr(0,0);
iBufferPtr.Set(TPtr8((TUint8*)&iInfo,sizeof(Info)));


//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(221,208,196,46)
TInetAddr remoteAddr(INET_ADDR(127,0,0,1), 7788);
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);



sock.Write(iBufferPtr,status);

//sock.Write((TDesC8 *)&iInfo,status);
User::WaitForRequest(status);
delete iInfo;
iInfo = NULL;
}
发送字符串的时候就能发出去, 而当发送结构体就会什么也发送不出去,求解

------解决方案--------------------
我都是发生字符串,其实你可以根据某协议(自定义协议)把结构体弄成字符串发生过去,对面接到字符串再还原成结构体就OK了
------解决方案--------------------
探讨

我都是发生字符串,其实你可以根据某协议(自定义协议)把结构体弄成字符串发生过去,对面接到字符串再还原成结构体就OK了
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: