Scott Mansfield wrote: > Anyways, I was struggling with some vagueness in the BeBook. In the > BNetEndpoint class the Socket accessor returns member data (an int, > from a call to ::socket()). The BeBook states that this accessor > "Returns the actual socket used by the BNetEndpoint for data > communications." Here are my concerns: > 1. What if a particular instance is not initialized, do I return > B_NO_INIT (or B_ERROR)? These are not sockets. Yes, I know that You can write a test program to see what BeOS R5 returns, but I guess returning B_ERROR or -1 (both are the same) is the correct way, as -1 is a valid invalid- socket/file descriptor :) > BNetEndpoint's consumer is supposed to call "InitCheck()" and act > accordingly before doing anything else -- but we're not living in a > perfect world; I've seen way too much bad windoze code to know > otherwise. Doesn't matter. The implementation of each function must be able to be called anytime, and must return an error code if the object is not initialized properly. > 2. We return a non-const 'fd' to an opened socket, free for our caller Yes, the caller can do what ever he likes with it. > to trounce upon willy-nilly. Our caller can even close( socket ) on Not a problem, any socket function called with this descriptor as parameter after it was closed will return an error code. > us, leaving whatever instance of BNetEndpoint 'socket' came from in an > indeterminate state. No, the functions will simply fail (including the final (duplicate)) close() call. Marcus