From: mockturtle <framefritti@gmail.com>
Subject: Funny thing with GNAT Socket?
Date: Thu, 12 Nov 2009 11:28:22 -0800 (PST)
Date: 2009-11-12T11:28:22-08:00 [thread overview]
Message-ID: <a21c3202-38c3-4c31-a4fc-55070a1e33a4@m26g2000yqb.googlegroups.com> (raw)
Dear all,
I have a strange problem (which, actually, is a problem only because I
have to use a buggy server) with the following code that sends an HTTP
request to the port 3000 of localhost (server and program run on the
same PC)
-------
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;
with Ada.Streams; use Ada.Streams;
with Ada.Characters.Latin_1;
procedure main is
Sock : Socket_Type;
Server : Sock_Addr_Type := (Family => Family_Inet,
Addr => Inet_Addr("127.0.0.1"),
Port => Port_Type(3000));
Basic_Stream : Stream_Access;
Query : String := "GET /p2p.rb?
stream=pippo&command=join_user&user=127.0.0.1:48946:3 HTTP/1.1";
Crlf : String := Ada.Characters.Latin_1.CR &
Ada.Characters.Latin_1.LF;
Host_name : String := "Host: 127.0.0.1:3000";
begin
Create_Socket (Sock);
Connect_Socket (Sock, Server);
Basic_Stream := Stream (Sock);
String'Write(Basic_Stream, Query);
String'Write(Basic_Stream, Crlf);
String'Write(Basic_Stream, Host_Name);
String'Write(Basic_Stream, Crlf);
String'Write(Basic_Stream, Crlf);
end main;
------
If I compile the code at home and check the traffic with tcpdump, I
can see that each strings is transmited in a packet by itself.
If I compile the code above at work, I see that the strings are
transmitted one char per packet (i.e., first a packet with "G", then a
packet with "E", and so on...) . It seems that the server does not
like this and it closes the connection without replying. However,
sometime (in a random fashion) after sending few single char packets,
it send the remainder of the string in a single packet. In this case
the server replies.
[Yes, the server is buggy since it should not care... Anyway, that is
what I have to use. Before you object, it is just to carry out some
fast-and-dirty tests, so it does not matter much if the system is a
little "brittle".].
We tried several tests. For example, if we use C (I'll have to whash
my keyboard with soap... ;-) or Ruby, each string is sent in a packet
by itself, both at home and at work. I am beginning to think that
this is something in the GNAT library and how it interfaces with BSD
sockets.
Ideas?
My environments:
Work : GPS 4.3.1 and GNAT 4.3.2 (from "About"), Linux 2.6.something
Home: GPS 4.3.1 and GNAT GPL 2009 (20090519), Linux 2.4.26
Thank you in advance.
next reply other threads:[~2009-11-12 19:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-12 19:28 mockturtle [this message]
2009-11-12 20:32 ` Funny thing with GNAT Socket? Dmitry A. Kazakov
2009-11-12 20:46 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox