comp.lang.ada
 help / color / mirror / Atom feed
From: "fabio de francesco" <fmdf@tiscali.it>
Subject: Re: TCP/IP Sockets with GNAT.Sockets
Date: 3 May 2005 05:04:05 -0700
Date: 2005-05-03T05:04:05-07:00	[thread overview]
Message-ID: <1115121845.628611.115440@g14g2000cwa.googlegroups.com> (raw)
In-Reply-To: <42769264$0$28069$ba620e4c@news.skynet.be>

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




  reply	other threads:[~2005-05-03 12:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-02  2:42 TCP/IP Sockets with GNAT.Sockets fabio de francesco
2005-05-02  5:58 ` Eric Jacoboni
2005-05-02 12:11 ` Adrien Plisson
2005-05-02 14:55   ` fabio de francesco
2005-05-02 16:10     ` Adrien Plisson
2005-05-02 17:56       ` Eric Jacoboni
2005-05-02 18:30         ` Poul-Erik Andreasen
2005-05-02 19:10           ` Simon Wright
2005-05-03 13:00             ` Poul-Erik Andreasen
2005-05-03 21:48               ` Simon Wright
2005-05-04  8:01               ` Character'First, ASCII.NUL and others (Was: Re: TCP/IP Sockets with GNAT.Sockets) Adrien Plisson
2005-05-04 13:40                 ` Poul-Erik Andreasen
2005-05-02 20:37           ` TCP/IP Sockets with GNAT.Sockets fabio de francesco
2005-05-02 20:52             ` Adrien Plisson
2005-05-03 12:04               ` fabio de francesco [this message]
2005-05-03 12:22                 ` Adrien Plisson
2005-05-03 13:17             ` Poul-Erik Andreasen
2005-05-02 20:44         ` Adrien Plisson
2005-05-02 22:10           ` Eric Jacoboni
2005-05-02 23:42             ` tmoran
2005-05-02 19:39     ` Björn
2005-05-02 20:22       ` fabio de francesco
2005-05-09  4:03         ` Dave Thompson
replies disabled

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