comp.lang.ada
 help / color / mirror / Atom feed
* Funny thing with GNAT Socket?
@ 2009-11-12 19:28 mockturtle
  2009-11-12 20:32 ` Dmitry A. Kazakov
  2009-11-12 20:46 ` Jacob Sparre Andersen
  0 siblings, 2 replies; 3+ messages in thread
From: mockturtle @ 2009-11-12 19:28 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-12 20:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-12 19:28 Funny thing with GNAT Socket? mockturtle
2009-11-12 20:32 ` Dmitry A. Kazakov
2009-11-12 20:46 ` Jacob Sparre Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox