I'm working on UDP communications using Ada. This code has to send some data to another host which is going to process it. I'm trying to send an initial message to start the communication, but it doesn't work. My client code is the following:
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;
I'm using Wireshark to view the inbound traffic, but it doesn't receive anything.