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-Thread: 103376,7db5fb0599fd4b76 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g14g2000cwa.googlegroups.com!not-for-mail From: "fabio de francesco" Newsgroups: comp.lang.ada Subject: Re: TCP/IP Sockets with GNAT.Sockets Date: 3 May 2005 05:04:05 -0700 Organization: http://groups.google.com Message-ID: <1115121845.628611.115440@g14g2000cwa.googlegroups.com> References: <1115001752.291144.218410@z14g2000cwz.googlegroups.com> <427618e9$0$7743$ba620e4c@news.skynet.be> <1115045740.838321.306480@g14g2000cwa.googlegroups.com> <42765108$0$22419$ba620e4c@news.skynet.be> <020520051956181888%jaco@neottia.net> <427671d4$0$166$edfadb0f@dread11.news.tele.dk> <1115066261.409185.133090@o13g2000cwo.googlegroups.com> <42769264$0$28069$ba620e4c@news.skynet.be> NNTP-Posting-Host: 80.181.52.213 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1115121850 3166 127.0.0.1 (3 May 2005 12:04:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 3 May 2005 12:04:10 +0000 (UTC) In-Reply-To: <42769264$0$28069$ba620e4c@news.skynet.be> User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g14g2000cwa.googlegroups.com; posting-host=80.181.52.213; posting-account=Lp02jQ0AAABMd3TAghNf0TM2YBZqD_JE Xref: g2news1.google.com comp.lang.ada:10894 Date: 2005-05-03T05:04:05-07:00 List-Id: Adrien Plisson wrote: > fabio de francesco wrote: > > How can you know a priori if a remote service is coded in C or Ada or > > everything else? > you don't and you should NEVER assume such a thing. but you should know > what protocol is to be used between the client and the server. if the > protocol is well-defined (that is: in a language independant way) there > is no problem in making any software in any language communicate... Ciao, I know that. I've been programming networking software in C for years. I only objected to that statement: "... however If the other end of the socket is a C-style server it will probely demand somthing like the following:..." > > Is your code reading character by character? If it is I don't think you > > can use it for designing efficient programs. > why not ? I supposed that Ada and C aren't different in that. I mean that, when a C program is to read/write a lot of data from/to a disk file or any other device, it is preferred to read/write large chunks of bytes altogether: FILE *in, *out; size_t nread; char buffer[BUFSIZ]; in = fopen ("file.in", "r"); out = fopen ("file.out", "w"); while ((nread = fread(buffer,sizeof(char),sizeof(buffer),in)) > 0) fwrite(buffer,sizeof(char),nread,out); fclose (in); fclose (out); The first code is faster (20% on my machine) than the following: char b; while ((nread = fread(&b,sizeof(char),1,in)) > 0) fwrite(&b,sizeof(char),1,out); > another question for you: do you use TCP connections to send small > packets ? those TCP frames that can achieve more than 50% overhead are > really not efficient... What does make you think that? If you refer to my posted code, it was only a test to get acquainted to GNAT.Sockets. > > May be your C-counterpart program > > contains an algorithm that knows how to do it. > > or simply ignore those characters which are non-printable, which is the > case with small strings... > > -- > rien Regards, fabio de francesco