ROOT 2.20/06, Solaris 5.6 Dear ROOTers, I have a small problem with controlling socket's activity. To illustrate it, let us do the following in CINT. (The line numbers indicate the order in which to execute commands, in two different root sessions.) CASE 1---------------------------------------------------------------- ### Server - session 1 1: TServerSocket *ss = new TServerSocket(9090,kTRUE) 2: TSocket *s = ss->Accept() 6: char str[32]; 7: s->Recv(str,32) //return value==3 8: s->Recv(str,32) //return value==(-1) as expected plus an error //message - everything OK ### Client - session 2 3: TSocket *s = new TSocket("localhost",9090) 4: s->Send("HI") 5: .q //now, let's just kill the client. CASE 2 --------------------------------------------------------------- ### Server - session 1 1: TServerSocket *ss = new TServerSocket(9090,kTRUE) 2: TSocket *s = ss->Accept() 6. TMessage *mess; 7. s->Recv(mess) //return value==7 - OK. 8. free(mess); 9. s->Recv(mess) //return value==7 <-this is the problem (*) ### Client - session 2 3: TSocket *s = new TSocket("localhost",9090) 4: s->Send("HI") 5: .q //now, let's just kill the client. ---------------------------------------------------------------------- (*) One would expect to have -1 as in the first case. Moreover, in the latter case (in session 1) we have no way of determining whether the connection has been broken or not since : -> s->IsValid() returns kTRUE -> s->GetErrorCode() returns 0 And besides, this is not what the documentation says: Recv(TMessage&) "...Receive a TMessage object. The user must delete the TMessage object. Returns length of message in bytes (can be 0 if other side of connection is closed) or -1 in case of error or -4 in case a non-blocking socket would block (i.e. there is nothing to be read). In those case mess == 0." I would like to thank you in advance for your comments, Best regards, Krzysztof _____________________________________________________________________ Krzysztof Wiktor Zelazowski Email: Krzysztof.Zelazowski@cern.ch Etudiant technique div.EP |CERN| Tel.: +41 (22) 767 2382 _____________________________________________________________________
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET