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

请问Symbian下Socket编程

发布时间:2010-05-30 00:31:18 文章来源:www.iduyao.cn 采编人员:星星草
请教Symbian下Socket编程!
想编写一个简单的传字符串的Socket程序,如下面代码,运行后,会陷入等待,过会儿客户端出现E32USER_CBase   46,服务器端出现ViewSrv   11   的错误。请大家帮忙解看看什么问题,谢谢!

服务器端:
RSocketServ   ss;
RSocket   listenSocket;
RSocket   serviceSocket;
TRequestStatus   status;

User::LeaveIfError(ss.Connect());
CleanupClosePushL(ss);
User::LeaveIfError(listenSocket.Open(ss,KAfInet,KSockStream,KUndefinedProtocol));
CleanupClosePushL(listenSocket);
User::LeaveIfError(serviceSocket.Open(ss));
CleanupClosePushL(serviceSocket);

TInetAddr   httpAddr(KInetAddrAny,8000);
listenSocket.Bind(httpAddr);

listenSocket.Listen(3);
listenSocket.Accept(serviceSocket,status);
User::WaitForRequest(status);

TBuf8 <60>   buf;
TSockXfrLength   iLen;
serviceSocket.RecvOneOrMore(buf,0,status,iLen);

CleanupStack::PopAndDestroy(3,&ss);

客户端:
RSocketServ   ss;
RSocket   sock;
TRequestStatus   status;
User::LeaveIfError(ss.Connect());
CleanupClosePushL(ss);
User::LeaveIfError(sock.Open(ss,KAfInet,KSockStream,KProtocolInetTcp));
CleanupClosePushL(sock);

TSockAddr   destAddr(KInetAddrLoop);
destAddr.SetFamily(KAfInet);
destAddr.SetPort(8000);
sock.Connect(destAddr,status);

_LIT8(KSendData, "How   are   you! ");
TBufC8 <50>   buf(KSendData);
sock.Send(buf,KSockWriteUrgent,status);
User::WaitForRequest(status);

CleanupStack::PopAndDestroy(2,&ss);

------解决方案--------------------
ViewSrv 11 应该和你贴出来的代码没什么关系吧
应该是ui的错误
KERN-EXEC 3 错误的解释:
This panic is raised when an unhandled exception occurs. Exceptions have many causes, but the most common are access violations caused, for example, by dreferencing NULL. Among other possible causes are: general protection faults, executing an invalid instruction, alignment checks, etc.

你可以调试一下
应该可以查出来的
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: