soadlink Posted September 7, 2006 Share Posted September 7, 2006 Hello,I was wondering (since PHP is very powerful) if it was possible to connect to a certain IP and port of a server that accepts connections on that port, send strings of data, and receive data that the server sends. <-- all of course with php.So I am basically looking to see if there is a Winsock 6.0 (a visual basic control) equivelent with PHP code.Hope that explains it, thanks! ;D Quote Link to comment Share on other sites More sharing options...
R_P Posted September 7, 2006 Share Posted September 7, 2006 Sure. Take a look at this tutorial: http://www.phpfreaks.com/tutorials/50/0.phpYou need to have the php sockets module compiled with PHP. The tutorial will then show you how to open, connect to, and listen on a socket. Quote Link to comment Share on other sites More sharing options...
soadlink Posted September 8, 2006 Author Share Posted September 8, 2006 Thanks for the help! I have played with this tutorial, and I know I coded my test page correctly, but when I load it the page just sits there. Is this because the php sockets module wasnt compiled as you said it must be?Here is my code:[code]<?$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);$connection = socket_connect($socket,'gpcm.gamespy.com',29900);while($data = socket_read($socket,2046,PHP_NORMAL_READ)) //listen for any data, and echo that data out{echo $data;}?>[/code]After connecting, that server (gpcm.gamespy.com:29900) should automatically send back a reply without the client sending anything. But I get nothing, just a page that appears to be loading forever. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.