bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CommonC++ questions/comments


From: W.J.
Subject: CommonC++ questions/comments
Date: Tue, 22 Apr 2003 08:41:36 +0200 (CEST)

Hi,

I seem to miss three things very badly in CommonC++, making it very
difficult or even impossible to do what I want:

- A decent way to do completely async network I/O. We have the SocketPort,
but that one lacks the ability to construct ports to listen in a (TCP)
machine/port address in asynchronous fashion. (There is a SocketPort()
constructor to create a bound UDP socket. Why not a TCP one?)

The SampleSocketPort example uses a seperate thread(!) to do the listening
and accepting part, I don't like this, furthermore the method used does
not work when we want to listen on multiple ports.

Another way for pseudo async i/o would have beee to use
Socket.isPending(), but this methods lacks a way to 'select' on
multiple sockets/streams.

- A SocketPort() constructor that creates a SocketPort from a already
existing Socket.
Would be useful if, like in my progam, the connection and initialisation
part is synchronous, but tha server main loop is async. (it is a
proxy-kind of application, that needs to watch two streams and convert
between them)

- TCPStream::readsome does not work as it should? It always returns
0, and reads nothing.
I thought the semantics of readsome should be 'wait for the first byte,
then read as much as is available'.

It is possible to circumvent this 'glitch' with the following
construction, though:

s.read(&buffer[0], 1);
n = s.readsome(&buffer[1], BUFSIZE-1) + 1;

I tried this too, without success (never gets anything even if data is
available):

if(s.isPending(Socket::pendingRead)) {
        n = s.readsome(&buffer, BUFSIZE);
}

[Operating system Linux 2.4.19 glibc 2.3.1, have not tested in win32 yet]

--

I could give a shot at implementing/fixing the above things myself, but
I'd like to know first if things are this way for a reason.

Wladimir





reply via email to

[Prev in Thread] Current Thread [Next in Thread]