Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

socket_read() does not exist?

Status
Not open for further replies.

jisoo23

Programmer
Jan 27, 2004
192
US
Hello,

I configured PHP5 RC1 with the --enable-sockets option but the socket_read method comes up as an undefined method. Here is the exact error message:

Code:
Fatal error: Call to undefined function socket_read() in /home/gpark/public_html/java/package1/test3.php on line 17

Does anyone know what's going on?

Thanks,
Jisoo23
 
*bonk self* I forgot the make, make install (I was re-configuring with enable-sockets). Don't mind me, I'm an idiot =P

I might ask one question though, I'm sending data through the socket just fine but I don't seem to be receiving any using socket_read(). Basically my PHP page uses these functions in the following order:

socket_create()
socket_connect()
socket_write()
socket_read()
socket_close()

Should I be using socket_listen() somewhere or something? I'm rather puzzled why my data doesn't reach my PHP. It's just a simple string being echoed.

Thanks,
Jisoo23
 
socket_listen() is used in situations where a PHP script will act like a server. A web server, for example, sits quietly listening on port 80 until a connection comes in.

Using sockets to send data to a web app can be complicated. You have to send the data into the connection in such a way that the web server will know what to pass to the script.

GET-method, which is on the URL is pretty easy. It's just appended to the GET statement as it would be with a browser.

POST-method requires more work.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
A-ha ok then. So socket_listen() is out of the question since I'm trying to create a PHP client page which accesses a piece of server software using a socket. This still leaves my question unanswered as to why socket_read() is an undefined function while socket_create(), socket_connect(), and socket_write() are available. Is socket_read() offered in some other extension aside from --enable-sockets?

What you're proposing using the GET method is interesting. My only question is how the data run through the socket will get to the URL so that the GET method can reach it?

Thanks,
Jisoo23
 
No, all I did with my installation (PHP 4.3.6 on Linux) was:[ol][li]hand the configure script "--enable-sockets" (as well as all my other configuration options),[/li][li]compile the software ("make"),[/li][li]Shut down Apache,[/li][li]intstall the software ("make install"), and[/li][li]Start Apache[/li][/ol]



Sending GET-method information is simply done by simply appending the data to the appropriate header you write to the socket:

GET /somescript.php[blue]?foo=3[/blue] HTTP/1.1





Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top