请教udp问题(100)

  • 主题发起人 主题发起人 cf83325
  • 开始时间 开始时间
C

cf83325

Unregistered / Unconfirmed
GUEST, unregistred user!
服务端:procedure 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;客服端:procedure 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;在一台机子上自己给自己发没有问题,可是在局网内发,服务端受不到。。什么原因啊?请教高手
 
珍爱生命,远离indy
 
没有错。这个程序是对的。网关的问题。。
 
后退
顶部