D
dxj1976
Unregistered / Unconfirmed
GUEST, unregistred user!
我用Tidtcpserver 做了一个通讯服务程序,来监听我们公司GPRS终端返回的一些数据,IP地址可以得到,但为什么就是没有数据呢?代码如下:var Form1: TForm1;implementationuses FunForm;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var bindings:Tidsockethandle;begin bindings:=IdTCPServer1.Bindings.Add; bindings.IP:=Edit1.Text; bindings.Port:=StrToInt(Edit2.Text); IdTCPServer1.Active:=true; Button1.Enabled:=false; Button2.Enabled:=true;end;procedure TForm1.Button3Click(Sender: TObject);begin close;end;procedure TForm1.FormCreate(Sender: TObject);begin Button1.Enabled:=true; Button2.Enabled:=false; Memo1.Clear;end;procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);var ipstr,str:string;begin str:=AThread.Connection.ReadLn; str:=hex_str1(str); Memo1.Lines.Add(str);end;procedure TForm1.Button2Click(Sender: TObject);begin IdTCPServer1.Active:=false; Button1.Enabled:=True; Button2.Enabled:=false;end;procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);var ipstr,str:string;begin ipstr:=AThread.Connection.Socket.Binding.PeerIP; Memo1.Lines.Add(ipstr);end;end.