C
cf83325
Unregistered / Unconfirmed
GUEST, unregistred user!
服务端rocedure TUDPMainForm.FormCreate(Sender: TObject);begin HostName.Caption := UDPServer.LocalName; HostAddress.Caption := GStack.LocalAddress; Port.Caption := IntToStr(UDPServer.DefaultPort); BufferSize.Caption := IntToStr(UDPServer.BufferSize); UDPServer.Active := True;end;procedure TUDPMainForm.UDPServerUDPRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);var DataStringStream: TStringStream; s: String;begin DataStringStream := TStringStream.Create(''); try DataStringStream.CopyFrom(AData, AData.Size); UDPMemo.Lines.Add('Received "' + DataStringStream.DataString + '" from ' + ABinding.PeerIP + ' on port ' + IntToStr(ABinding.PeerPort)); s := 'Replied from ' + UDPServer.LocalName + ' to "' + DataStringStream.DataString + '"'; ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, s[1], Length(s)); finally DataStringStream.Free; end;end;客服端rocedure TForm1.Button1Click(Sender: TObject);begin if edit1.text = '' then application.MessageBox('请输入服务器地址', '提示', mb_ok); if edit1.text <> '' then begin IdUDPClient1.Host := Edit1.Text; IdUDPClient1.Send(Memo1.Text); end; end;在一台机子上自己给自己发没有问题,可是在局网内发,服务端受不到。。什么原因啊?请教高手