我正在使用Ada进行UDP通信。这段代码需要向另一台主机发送一些数据进行处理。我试图发送初始消息以开始通信,但它没有起作用。我的客户端代码如下:
with GNAT.Sockets;
use GNAT.Sockets;
with Ada.Text_IO;
with Ada.Exceptions;
use Ada.Exceptions;
procedure Client_Send is
task Send is
entry Start;
entry Stop;
end Send;
task body Send is
Address : Sock_Addr_Type;
Socket : Socket_Type;
Channel : Stream_Access;
begin
accept Start;
-- See comments in Ping section for the first steps.
Address.Addr := Inet_Addr( "192.168.0.1" );
Address.Port := 7777;
Create_Socket (Socket,Family_Inet,Socket_Datagram);
Bind_Socket (Socket, Address);
Channel := Stream (Socket);
String'Output (Channel, "Hello world");
Free(Channel);
Ada.Text_IO.Put_Line ("Mesnaje Enviado");
Close_Socket (Socket);
accept Stop;
exception when E : others =>
Ada.Text_IO.Put_Line
(Exception_Name (E) & ": " & Exception_Message (E));
end Send;
begin
Initialize (Process_Blocking_IO => False);
Send.Start;
Send.Stop;
Finalize;
end Client_Send;
我正在使用Wireshark查看入站流量,但它没有接收到任何内容。