Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Socket::IsOpen BUG/FIX (?)
Socket::IsOpen BUG/FIX (?) [message #24489] Wed, 20 January 2010 07:57 Go to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
hi there

in socket.h:73
class Socket

bool IsOpen() const { return !!data; }


is maybe wrong, since the Data class provides an IsOpen(), to which it should map, right?

so maybe like this:
bool IsOpen() const { return (data)?(data->IsOpen():(false); }

or
bool IsOpen() const { return data && data->IsOpen(); }


or do i miss something??
Re: Socket::IsOpen BUG/FIX (?) [message #24497 is a reply to message #24489] Wed, 20 January 2010 21:23 Go to previous messageGo to next message
rylek is currently offline  rylek
Messages: 79
Registered: November 2005
Member
Hello!

Conceptually you are right. I think the main reason for this awkwardness is historical evolution of the socket interface. The socket wrapper (class Socket) in practice receives its Data object only when it's open (through the ClientSocket / ServerSocket functions) and Socket::Close clears the internal pointer after closing the socket, so that for practical purposes (until now) it sufficed to check validity of the pointer. However with support for SSL and other extensions it started to be easier to allow the Data object to remain closed for a certain (initial) period. This is mainly to allow internal creation and initialization of the socket implementor object within the ClientSocket / ServerSocket functions, i.e. within "internals" of the socket hackery. I'm not sure what would happen if someone tried to put an unopened Socket::Data object into a Socket class. I'll discuss this with Mirek in greater detail but in any case I'm sure the modification you suggest is completely harmless and might prove itself valuable when dealing with various exceptional socket circumstances.

Regards

Tomas
Re: Socket::IsOpen BUG/FIX (?) [message #24498 is a reply to message #24497] Wed, 20 January 2010 23:03 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
thanks, i'll use this meanwhile, just to intercept any occurence of side effects
Re: Socket::IsOpen BUG/FIX (?) [message #24518 is a reply to message #24498] Thu, 21 January 2010 23:01 Go to previous message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
I agree this should be harmless and it is logical too -> patch applied.
Previous Topic: Socket through Proxy server
Next Topic: MT with speed optimization fails
Goto Forum:
  


Current Time: Tue Aug 20 02:41:18 CEST 2019

Total time taken to generate the page: 0.01708 seconds