udp_genesis 1
udp_genesis 2
udp_genesis 3
udp_genesis 4
udp_genesis 5
udp_genesis 6
udp_genesis 7
udp_genesis 8
udp_genesis 9
udp_genesis 10
udp_genesis 11
udp_genesis 12
udp_genesis 13
udp_genesis 14
udp_genesis 15
udp_genesis 16
udp_genesis 17
udp_genesis 18
udp_genesis 19
udp_genesis 20 with Ada.Text_IO; use Ada.Text_IO;
udp_genesis 21
udp_genesis 22 with UDP;
udp_genesis 23
udp_genesis 24
udp_genesis 25 procedure UDP_Echo_Demo is
udp_genesis 26
udp_genesis 27 Socket : UDP.Socket;
udp_genesis 28
udp_genesis 29
udp_genesis 30
udp_genesis 31
udp_genesis 32
udp_genesis 33 Local_Endpoint : UDP.Endpoint := (Address => UDP.INADDR_ANY,
udp_genesis 34 Port => 7000);
udp_genesis 35
udp_genesis 36 Received_Payload : UDP.Payload;
udp_genesis 37 Received_Origin : UDP.Endpoint;
udp_genesis 38 Received_Valid : Boolean;
udp_genesis 39
udp_genesis 40 begin
udp_genesis 41 Put_Line("Opening socket on local endpoint " &
udp_genesis 42 UDP.IP_To_String(Local_Endpoint.Address) &
udp_genesis 43 " :" & UDP.IP_Port'Image(Local_Endpoint.Port) & "...");
udp_genesis 44
udp_genesis 45 UDP.Open_Socket(Socket, Local_Endpoint);
udp_genesis 46
udp_genesis 47 Put_Line("Waiting for payload...");
udp_genesis 48
udp_genesis 49 UDP.Receive(Socket, Received_Origin, Received_Payload, Received_Valid);
udp_genesis 50
udp_genesis 51 Put_Line("Received payload from " &
udp_genesis 52 UDP.IP_To_String(Received_Origin.Address) &
udp_genesis 53 " :" & UDP.IP_Port'Image(Received_Origin.Port) & "...");
udp_genesis 54
udp_genesis 55 if Received_Valid then
udp_genesis 56
udp_genesis 57 Put_Line("Sending received payload back to originator...");
udp_genesis 58
udp_genesis 59 UDP.Transmit(Socket, Received_Origin, Received_Payload);
udp_genesis 60
udp_genesis 61 else
udp_genesis 62
udp_genesis 63 Put_Line("Received short payload, ignored.");
udp_genesis 64
udp_genesis 65 end if;
udp_genesis 66
udp_errata_asciil... 67 UDP.Close_Socket(Socket);
udp_errata_asciil... 68
udp_genesis 69 Put_Line("Done.");
udp_genesis 70
udp_genesis 71 end UDP_Echo_Demo;