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

请教:C++Builder 如何写TCPIP Server程序,收发字节流?

2012-03-03 
请问:C++Builder 怎么写TCPIP Server程序,收发字节流??请问:C++Builder 怎么写TCPIP Server程序,收发字节

请问:C++Builder 怎么写TCPIP Server程序,收发字节流??
请问:C++Builder 怎么写TCPIP Server程序,收发字节流??



[解决办法]

C/C++ code
//C++Builder 6.0void __fastcall TForm1::Button1Click(TObject *Sender){  byte a[2] ={0xAA,0xBB} ;  IdTCPClient1->WriteBuffer(a,2,2);}void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread){   byte a[2] ;   AThread->Connection->ReadBuffer(a,2) ;   AnsiString s;   for(int i=0;i<2;i++)       s +=IntToHex(a[i],2);   Memo2->Lines->Add(s);}//---------------------------------------//C++Builder 2009void __fastcall TForm1::Button1Click(TObject *Sender){  if(!IdTCPClient1->Connected())  {     IdTCPClient1->Connect();   }   IdTCPClient1->IOHandler->WriteLn("汉字123abcd",enUTF8);   IdTCPClient1->Disconnect();}//TIdTCPServer端的onExcute事件: void __fastcall TForm2::IdTCPServer1Execute(TIdContext *AContext) {    UnicodeString CmdString =AContext->Connection->IOHandler->ReadLn(enUTF8); } 

热点排行