Re: TCP/IP Sockets with GNAT.Sockets
- From: Poul-Erik Andreasen <poulerik@xxxxxx>
- Date: Tue, 03 May 2005 15:17:19 +0200
fabio de francesco wrote:
Poul-Erik Andreasen wrote:
[...]
I have, actually i am using it rigth now and i works. however If the other end of the socket is a C-style server it will probely demand somthing like the following:
How can you know a priori if a remote service is coded in C or Ada or everything else?
You can't, but i make no differens as long as you have the API. If the API requires zeroterminated strings it what you could call a c-style API. It can be written in any langauge, also in Ada and ' still be a C.style
String'Write( Channel, "Hello" & character'first);
when i read i read characters and stop when i reach character'first.
Here is a fixed string sulution
declare Channel := Stream( Socket ); Word : string(1.. max_word); counter : natural := 1 begin loop word(counter) := Character'Input (Channel); exit when word(counter) = Character'First; counter := counter + 1; end loop; -- her do what you have to do with Word(1..(counter -1)) end;
Is your code reading character by character? If it is I don't think you can use it for designing efficient programs.
At some level the program vill have to deal with bytes individualy anyway, you could asume that the build in procedure are better
optimized, but i dont think that the overhead is significant
as long as you use a fixed string as buffer. If you using unbounded_strings, and are adding the incomming character it is a quite different story;
BTW my C-couterpart program dosn't seems to have anything against String'Output( Channel, "Hello" & character'first) ?
What I understand from this thread is that T'Output and T'Input add some metadata to the stream. If it is true, communicating programs in other languages must know how to read/write the streams in order to differentiate data from metadata. May be your C-counterpart program contains an algorithm that knows how to do it.
Yes it requere a special start character.
Greeting
Poul-Erik Andreasen .
- References:
- Re: TCP/IP Sockets with GNAT.Sockets
- From: Adrien Plisson
- Re: TCP/IP Sockets with GNAT.Sockets
- From: fabio de francesco
- Re: TCP/IP Sockets with GNAT.Sockets
- From: Adrien Plisson
- Re: TCP/IP Sockets with GNAT.Sockets
- From: Eric Jacoboni
- Re: TCP/IP Sockets with GNAT.Sockets
- From: Poul-Erik Andreasen
- Re: TCP/IP Sockets with GNAT.Sockets
- From: fabio de francesco
- Re: TCP/IP Sockets with GNAT.Sockets
- Prev by Date: Re: TCP/IP Sockets with GNAT.Sockets
- Next by Date: Re: xmlada and tree_readers.ads
- Previous by thread: Re: TCP/IP Sockets with GNAT.Sockets
- Next by thread: Re: TCP/IP Sockets with GNAT.Sockets
- Index(es):
Relevant Pages
|