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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ca576e395f501a7a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!news2.euro.net!newsfeed.freenet.de!news.tu-darmstadt.de!news.belwue.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Funny thing with GNAT Socket? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Thu, 12 Nov 2009 21:32:12 +0100 Message-ID: <1xcwbvayauo7$.1kat2jmsyqdn6$.dlg@40tude.net> NNTP-Posting-Date: 12 Nov 2009 21:32:07 CET NNTP-Posting-Host: 7b906b39.newsspool1.arcor-online.net X-Trace: DXC=DR^n53KSeVng`45cDR8l?oic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbMahglTXFWI][c X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8074 Date: 2009-11-12T21:32:07+01:00 List-Id: On Thu, 12 Nov 2009 11:28:22 -0800 (PST), mockturtle wrote: > 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) [...] > 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...) When you write an array into a stream using the attribute 'Write, the compiler has right to implement this as individual writings of the array elements. Newer versions of GNAT coalesce string writing into several characters at once, the older ones do not. So the first thing to do is to use Stream operations rather than the attributes. E.g. Write procedure Write( Stream : in out Root_Stream_Type; Item : in Stream_Element_Array) Even better would be to use Send from GNAT sockets. With Send you can be certain that the packet will be split only if the transport layer urgently will do this. Another thing is a strange behavior of the socket (TCP stack), which normally coalesces small packets. There is a TCP_NO_DELAY option which controls this behavior. By default it is false, i.e. coalescing is on. Make sure that you don't set it to true when you create the socket. You can also set it to false explicitly. > 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 See, the compilers are indeed different! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de