Jump to content

PHP Misspeak or Misunderstanding


iwato
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...