object UdpSocket1: TUdpSocket
Active = True
BlockMode = bmNonBlocking
LocalHost = '127.0.0.1'
LocalPort = '2020'
RemoteHost = '127.0.0.1'
RemotePort = '2030'
OnReceive = UdpSocket1Receive
Left = 304
Top = 120
end
object UdpSocket2: TUdpSocket
Active = True
BlockMode = bmNonBlocking
LocalHost = '127.0.0.1'
LocalPort = '2030'
RemoteHost = '127.0.0.1'
RemotePort = '2020'
OnReceive = UdpSocket2Receive
Left = 384
Top = 128
end
procedure TForm1.Button1Click(Sender: TObject);
begin
UdpSocket1.Sendln('aaa!');
end;
procedure TForm1.UdpSocket1Receive(Sender: TObject; Buf: PChar;
var DataLen: Integer);
begin
ShowMessage(Buf);
end;
procedure TForm1.UdpSocket2Receive(Sender: TObject; Buf: PChar;
var DataLen: Integer);
begin
ShowMessage(Buf);
end;
//remotehost:=remoteip
//remoteport:=3333;
去掉这个是不行的,不可能没要发送地址和端口。上面是我写代码,错在什么地方?
张大侠是否有例子,给个例子好吗? manniuyemanniu@163.com,manniuyemanniu@sina.com
manniuyemanniu@sohu.com
我确实没看见例子....,我到看见了INDY的例子和NMUDP的例子,而且已经可以用了,但是
这个不能用,心里老不舒服,源代码也看了看,不过没看的怎么清楚。哈哈。
你先看看delphi的例子,在例子基础上改,你应该没有错。