请问:C++Builder 怎么写TCPIP Server程序,收发字节流??
请问:C++Builder 怎么写TCPIP Server程序,收发字节流??
[解决办法]
//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); }