Jump to content

Connect to a server, send packets, receive packets.


soadlink

Recommended Posts

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
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.