使用TWinSocketStream::Read的时候Read error 64,请问是什么原因?

zuoyefeng 2006-07-04 11:37:09
使用TWinSocketStream::Read时报错 Read error 64指定的网络名不再可用
代码如下,请问是什么原因,该如何解决
if (pStream->WaitForData(60000))
{ //if10
if(!ClientSocket->Connected)
{
Terminate();
return;
}

Sleep(2500);
recvlen = pStream->Read(recv_buf, 1024);
...全文
706 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liqingle 2006-08-09
  • 打赏
  • 举报
回复
xuexi
僵哥 2006-08-04
  • 打赏
  • 举报
回复
ErrorCode=64,其实就是网络连接已断开.
ttii 2006-07-31
  • 打赏
  • 举报
回复
我也遇到过同样问题,后来发现帮助里面有一个模型,按照他那个模型就对了,我理解TWinSocketStream这个东西是在一次通信那么就建立一个,用完就delete了,这样看来效率不是很高啊,不过只得这样用了,不然就自己用winsocket函数
痞子酷 2006-07-10
  • 打赏
  • 举报
回复
The following example shows a typical ClientExecute method for a custom descendant of TServerClientThread. It reads from the socket connection specified by ClientSocket using a thread-local instance of TWinSocketStream.

void __fastcall TMyServerThread::ClientExecute(void)

{
TWinSocketStream *pStream;
char Buffer[10];
// make sure connection is active
while (!Terminated && ClientSocket->Connected)
{
try
{
Stream = new TWinSocketStream(ClientSocket, 60000);
try
{
memset(Buffer, 0, 10); // initialize the buffer
// give the client 60 seconds to start writing
if (pStream->WaitForData(60000))
{
if pStream->Read(Buffer, 10) == 0) // if can抰 read in 60 seconds

ClientSocket->Close(); // close the connection
// now process the request
...
}
else
ClientSocket->Close(); // if client doesn抰 start, close
}
__finally
{
delete pStream;
}
}
catch (Exception &E)
{
HandleException();
}
}
}
痞子酷 2006-07-10
  • 打赏
  • 举报
回复
WaitForData(60000));就是等待
Sleep(2500);这个可以不要。
zuoyefeng 2006-07-04
  • 打赏
  • 举报
回复
另外与Sleep(2500);没关系
zuoyefeng 2006-07-04
  • 打赏
  • 举报
回复
recvlen = pStream->Read(recv_buf, 1024);
在这里就出错了
真是奇怪

1,316

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧