bug-commoncpp
[Top][All Lists]
Advanced

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

client-server streaming of data...does isPending work on error if you on


From: Mike Papper
Subject: client-server streaming of data...does isPending work on error if you only set the pendingInput flag?
Date: Thu, 25 Sep 2003 20:41:28 -0700

Running on linux...
I have a program that uses a subclass of TCPSocket to create a new thread and 
hand off the connection to a TCPSession.

The code is from some example somewhere, its like this:
loop
  subclassTCPSocket listen(Addr);
  if (listen.isPendingConnection(timeout)) {
    tcp = new ecsTCPSession(server);
    tcp.detach();
  end for
end loop

In the TCPSession (thread):
if (isPending(Socket::pendingInput, 1000)) {
      string tmp_data;
      *tcp() >> tmp_data;
      break;
}
tcp() << "Hello from server " << endl;
// and the thread dies (and to verify, I do see debug output in its 
destructor)

1) Is there any good documentation on how to use this class library?
2) Is there a better way to read and send characters on the TCPSession rather 
than using the stream operators? I.e., I would like something that told me 
how many characters it read (and suggested how many characters I had in my 
buffer). The call to *tcp() >> tmp_data doesnt really tell me how much was 
read in and in fact seems to read only up to the first space character. I 
found a methd called read() but it seems very broken (hangs).
3) Does the call to isPending take a bitmask of the Pending values, such as 
Socket::pendingInput | Socket::pendingOutput | Socket::pendingError?
Shouldnt it be mandatory to always look for an error or else we will be 
blocked in this fucntion forever if there was an error? Or will isPending 
return (false) if the socket is closed or some other underlying socket error 
occurs????
4) Can I use the >> operator (as in "*tcp() << string") (without calling 
isPending) to read input from the socket and assume that is a blocking read? 
5) One must assume that if we call isPending and get "true" that by the time 
the next line of code executes, there may not be any data on the socket or 
the connectionmay have closed.
Thus the use of the stream operator ("*tcp() << string") must be able to deal 
with failures.  How is this done? Is an exception thrown??

Any help with how to do standard client-server is appreciated due to lack of 
good docs for this library...

-- 
Mike Papper
Fantastic
address@hidden
650-356-2113





reply via email to

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