首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

线程中idTCPClient连接的有关问题

2012-02-23 
线程中idTCPClient连接的问题C/C++ codevoid __fastcall MyThreadForTcpClient::Execute(){//---- Place t

线程中idTCPClient连接的问题

C/C++ code
void __fastcall MyThreadForTcpClient::Execute(){    //---- Place thread code here ----    Synchronize(GETMSG);}//---------------------------------------void  __fastcall MyThreadForTcpClient::GETMSG(){    TIdTCPClient *IdTCPClient;    //ShowMessage("Hello");    IdTCPClient->Port = IdTCP->EditServerPort->Text.ToInt();    IdTCPClient->Host = "127.0.0.1";    IdTCPClient->Connect();    if(IdTCPClient->Connected() == true)    {        //ShowMessage("Hello");        UnicodeString MGS = "";        for(;;)        {            MGS = IdTCPClient->Socket->ReadLn(enUTF8);            if(MGS != "")            {                IdTCP->EditReceiveMessage->Text = MGS;                MGS = "";            }            Sleep(1000);        }    }}


我把IdTCPClient放在这个线程中为什么连不到服务器端?

本来想 听服务器端发来消息的,但发现在Timer控件中听的时候程序很卡,大家怎么解决的啊?

[解决办法]
Synchronize是在主线程中执行了

你在主线程中无限循环?
[解决办法]
IdTCPClient没有初始化,居然没有AV?
[解决办法]
探讨
IdTCPClient没有初始化,居然没有AV?

热点排行