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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,653092a494425539,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-11 12:39:22 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mutilation@bonbon.net (wave) Newsgroups: comp.lang.ada Subject: Sockets Example Date: 11 Apr 2004 12:39:21 -0700 Organization: http://groups.google.com Message-ID: <4d01ad29.0404111139.58cd3e55@posting.google.com> NNTP-Posting-Host: 62.252.128.11 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1081712362 21538 127.0.0.1 (11 Apr 2004 19:39:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 11 Apr 2004 19:39:22 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:6984 Date: 2004-04-11T12:39:21-07:00 List-Id: Hello there, I was wondering if anybody could provide some socket examples for ada as I've looked everywhere and only found really pretty basic things (ie the header of the gnat.sockets package) Could anybody explain to me how you'd go about querying a http server and getting a response? Even retrieve a specific file? The code I'm trying to use below isnt working as I'd of expected it too, and I know it's probably not even remotely close to how it should be! with Gnat.Sockets; use Gnat.Sockets; with Ada.Text_Io; use Ada.Text_Io; procedure meh is Socket : Socket_Type; Server : Sock_Addr_Type; Channel : Stream_Access; begin Initialize; Create_Socket (Socket, Family_Inet, Socket_Datagram); Server := ( Addr => Addresses (Get_Host_By_Name ("www.adahome.com"), 1), Port => 80, Family => Family_Inet ); -- ? Bind_Socket (Socket, Server); Connect_Socket (Socket, Server); Channel := Stream (Socket); -- Some (hopefully correct) example of how to submit the correct data to the webserver, with carrige returns and line feeds. String'Output (Channel, "GET /index.html HTTP/1.1" & Character'Val(13) & Character'Val(10) & "Host: www.adahome.com" & Character'Val(13) & Character'Val(10) & "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040407 Firefox/0.8.0+" & Character'Val(13) & Character'Val(10) & "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" & Character'Val(13) & Character'Val(10) & "Accept-Language: en-us,en;q=0.5" & Character'Val(13) & Character'Val(10) & "Accept-Encoding: gzip, deflate" & Character'Val(13) & Character'Val(10) & "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & Character'Val(13) & Character'Val(10) & "Keep-Alive: 300" & Character'Val(13) & Character'Val(10) & "Cache-Control: max-age=0" & Character'Val(13) & Character'Val(10) & "Connection: keep-alive" & Character'Val(13) & Character'Val(10) ); loop declare Message : String := String'Input (Channel); begin Server := Get_Address (Channel); Put_Line (Message & " from " & Image (Server)); end; end loop; Close_Socket (Socket); end meh; Cheers for ANY insight into my problem you people can give. Mut.