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=0.1 required=5.0 tests=BAYES_00,FAKE_REPLY_C, MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC,WEIRD_PORT autolearn=no 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 05:28:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fr.usenet-edu.net!usenet-edu.net!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: GNAT.sockets UDP Example Date: Sun, 17 Nov 2002 07:26:52 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1037539684 32080 137.194.161.2 (17 Nov 2002 13:28:04 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sun, 17 Nov 2002 13:28:04 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: lemchens@lemmies.lb.bawue.de Xref: archiver1.google.com comp.lang.ada:31007 Date: 2002-11-17T07:26:52-06:00 "arvids lemchens" wrote in message news:8a2dx5TkACB@lemmies.lb.bawue.de... > 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)); The compiler messages mean exactly what they say. You need to read and understand them. For a connectionless socket, you need the four-parameter version of Send_Socket, otherwise the destination address is unspecified, so you need Send_Socket (Socket, Kahnung, Last, Address); where Last has been declared as: Last : Ada.Streams.Stream_Element_Offset; You really need to read and understand the GNAT>Sockets specification, and the comments which accompany each item. > -- 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 > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada > >