From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dfddb85b5a048f08 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-17 03:55:42 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-stu1.dfn.de!news.belwue.de!contact.softwarezentrum.de!news.bawue.de!lemmies.lb.bawue.de!not-for-mail From: lemchens@lemmies.lb.bawue.de (arvids lemchens) Newsgroups: comp.lang.ada Subject: Re: GNAT.sockets UDP Example Date: 17 Nov 2002 12:29:00 +0100 Organization: A poorly-maintained Debian GNU/Linux InterNetNews site Sender: news@pd9e623bc.dip.t-dialin.net Message-ID: <8a2dx5TkACB@lemmies.lb.bawue.de> References: <8$vYrY3kACB@lemmies.lb.bawue.de> NNTP-Posting-Host: pd9e623bc.dip.t-dialin.net X-Trace: pc3.dv-lemchens.de 1037532594 29826 192.168.2.6 (17 Nov 2002 11:29:54 GMT) User-Agent: OpenXP/32 v3.8.7pl1 (Linux) beta @ 2002-10-01-0656f Xref: archiver1.google.com comp.lang.ada:30997 Date: 2002-11-17T12:29:00+01:00 List-Id: Hello David, david.c.hoos.sr@ada95.com am 16.11.02 um 05:27 in comp.lang.ada: > ----- Original Message ----- > From: "arvids lemchens" >> Found one for TCP, but didn't get it to switch to UDP. >> Somehow it seems that i am to simpleminded for the "Send_Socket". > It's hard to guess what you might be doing wrong, without your code. Ok, stripped my code to the essentials: ----- with GNAT.Sockets; use GNAT.Sockets; with GNAT.Calendar.Time_IO; use GNAT.Calendar.Time_IO; with Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; with Ada.Calendar; use Ada.Calendar; with Interfaces; use Interfaces; with Ada.Streams; use Ada.Streams; procedure myrdate is Address : Sock_Addr_Type; Socket : Socket_Type; Channel : Stream_Access; LTime : Time; RTime : Unsigned_32; SockRet : Integer; Kahnung : Ada.Streams.Stream_Element_Array := (1, 2, 3); begin Initialize (Process_Blocking_IO => False); Address.Addr := Addresses (Get_Host_By_Name(Argument(1)), 1); Address.Port := 37; Create_Socket (Socket, Family_Inet, Socket_Datagram); -- Rest from TCP -- Connect_Socket (Socket, Address); -- Channel := Stream (Socket); Send_Socket (Socket, Kahnung, Kahnung(2)); -- Here should come Receive_Socket LTime := Clock; RTime := Unsigned_32'Input (Channel); -- Here should come Bitmanipulation Close_Socket(Socket); Finalize; end myrdate; ----- If i try to compile it: ----- ich@pc3:/transfer/ich2/ada/my/myrdate$ gnatmake -gnatf sendudp.adb gnatgcc -c -gnatf sendudp.adb sendudp.adb:10:11: warning: file name does not match unit name, should be "myrdate.adb" sendudp.adb:27:05: no candidate interpretations match the actuals: sendudp.adb:27:05: missing argument for parameter "To" in call to "send_socket" declared at g-socket.ads:653 sendudp.adb:27:35: expected type "Ada.Streams.Stream_Element_Offset" sendudp.adb:27:35: found type "Ada.Streams.Stream_Element" sendudp.adb:27:35: ==> in call to "Send_Socket" at g-socket.ads:645 gnatmake: "sendudp.adb" compilation error ich@pc3:/transfer/ich2/ada/my/myrdate$ ----- also tried different variants of the Send_Socket, but always there are (different) errors. Seems that i am missing some elementary knowledge about streams. > One guess -- did you create your socket like this? > Create_Socket (Socket, Family_Inet, Socket_Datagram); That part is ok. > How do you know that you didn't send correctly? Could the problem > be on the receiving end? No, it even doesn't compile. The Network itself is fine. > What platform/OS are you using? Linux. > I have used GNAT sockets for TCP, UDP (broadcast and point-to-point), > and multicast with great success, by none of my examples is short or > simple. Confusing too, i found that there seems to be two different Send_Socket's in GNAT-Sockets (using send and sendto). How do i know which the Compiler will use? Meanwhile i realized that also the Part with the Bitmanipulation is too complicated, at least for my current level of knowledge. So i am starting to think about some easier "Learning-by-doing"- exercises for me and leave the rdate for later. But if it is only a little modification do get above code running i would be appreciate for seeing possibel corrections. Thanks in advance. MvfG, Arvids