问一个Indy IdTCPServer基础问题

soloxiao 2006-04-21 11:21:37
我在BCB6中装了indy9写以下代码时发生错误:
void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
{
TIdTCPServerConnection * conn = AThread->Connection; //此处conn=NULL,不知何故
unsigned char buf[1024];
try{
conn->ReadBuffer(buf,1024);
}
catch(...)
{
Memo1->Lines->Add("TCP Read Error!");
return;
}
}

有简单的demo请发至 solo**xiao@yahoo.com.cn (将**去掉) 谢谢!
...全文
619 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zywx 2006-08-22
  • 打赏
  • 举报
回复
indy 8/9/10 每个版本的方法有很大区别,建议楼主先搞清楚用哪个版本
sczyq 2006-04-28
  • 打赏
  • 举报
回复
void __fastcall TForm1::IdTCPServerExecute(TIdContext *AContext)
{
TIdIOHandler * IOH = AContext->Connection->IOHandler;
TIdSocketHandle *ISH = AContext->Binding();

Memo1->Lines->Add("Client : " + ISH->PeerIP + ":" + IntToStr(ISH->PeerPort));

while (true)
try
{
AnsiString S = IOH->ReadLn();
if (S.Length()) Memo1->Lines->Add(S);
}
catch (...)
{
break;
}
}


以上很正确,只是使用了 Indy 10
soloxiao 2006-04-28
  • 打赏
  • 举报
回复
..............
soloxiao 2006-04-25
  • 打赏
  • 举报
回复
谢谢安吉儿,但是问题还是有,各位没有这个问题吗?
constantine 2006-04-23
  • 打赏
  • 举报
回复
为什么要用TIdTCPServerConnection * conn
直接读看看,这个我没有用过,觉得没有必要,
原因不清除

如果这个东西你没有用错有可能你装indy9有问题
soloxiao 2006-04-22
  • 打赏
  • 举报
回复
.......

1,317

社区成员

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

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