Re: TCP/IP Sockets with GNAT.Sockets



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
.



Relevant Pages

  • Re: How do I stop a Winsock from buffering characters?
    ... it's applied at the OS level to the socket. ... Stream s = client.GetStream; ... from the client code and have the server see it right away. ... first character of the client send. ...
    (microsoft.public.windowsce.embedded)
  • Re: CLISP + Araneida issues.
    ... Araneida also requests CLISP to make the stream with an ISO-8859-1 ... socket stream stream still does some bogus CR-LF recognition in spite ... character to the caller and leaves the following linefeed unread in the ... (lambda (stream subchar arg) ...
    (comp.lang.lisp)
  • Howto read line from a stream
    ... Channel: Stream_Access; ... This stream is associated with a socket. ... Or should I read character by character ...
    (comp.lang.ada)
  • Re: Help !!! Unable to connecte Asus 620
    ... inherit the connection problem. ... >> socket connection. ... >>>serial pin is low, possible cable problem. ...
    (microsoft.public.pocketpc.activesync)
  • Concurrent reader/writer threads on single socket
    ... I have what I imagine is a well-known .Net networking problem, ... one dedicated to reading from the socket and the other one ... BinaryWriter writer = new BinaryWriter); ... the output stream would hold a separate buffer ...
    (microsoft.public.dotnet.general)