iwato Posted July 16, 2011 Share Posted July 16, 2011 BACKGROUND: Do people volunteer to write manuals, or are they drafted? This is a rhetorical question that need not be answered. It is a prologue to the following statement that I recently extracted from the Online PHP Manual."The socket_getpeername() function should not be used with AF_UNIX sockets created with socket_accept(). Only sockets created with socket_connect() or a primary server socket following a call to socket_bind() will return meaningful values."QUESTION: To the best of my knowledge the socket_accept() and socket_connect() functions do not create sockets; rather, they use socket resources that have already been created to perform special tasks at those sockets. If I am correct, and I am not insisting that I am, how might one interpret the above statement meaningfully?You know there comes a time when I just want to sock it! Roddy Link to comment Share on other sites More sharing options...
justsomeguy Posted July 16, 2011 Share Posted July 16, 2011 Not all connections are equal. The only situation where a meaningful peer name would be returned is a certain type of connection set up like they describe. Link to comment Share on other sites More sharing options...
jeffman Posted July 16, 2011 Share Posted July 16, 2011 I think part of what Roddy is saying is that socket_accept() and socket_connect() return resources, not sockets. OTOH, socket_create also returns a resource. Conflating a socket with a socket resource is harmless enough for everyday conversation between developers. It is probably a bit sloppy for a manual.Then again, we all do this sort of thing all the time, including the manual. When we say strpos takes a string as an argument, that's really just sort of true. You can pass it a string literal, and then it sort of makes sense to say you're passing it a string. But if you pass a string function a variable to which a string has been assigned, you're really not passing it a string at all. You're passing it a reference to a location in a lookup table that points to another location in RAM. But it would really get annoying if we always talked about passing a "string reference" instead of "string." And no one ever complains when the manuals discuss string variables as if they were identical with the data that they reference.I suppose a resource is a different kind of data, and as I said, probably the manual should be more specific. But I don't think interpreting the description meaningfully is very difficult here. Where the passage you quoted has "socket" read "socket resource." Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.