Jump to content

php sockets problem..


RussellReal

Recommended Posts

ok I have this code.. its just experimental right now.. but its having problems

 

<?php
date_default_timezone_set('America/New_York');
error_reporting(E_ALL);
set_time_limit(0);
echo "lol\n";
$connection = socket_create_listen(4005);
socket_set_nonblock($connection);
$clients = array();
while (1) {
	echo socket_strerror(socket_last_error($connection))."\n";
	while ($new = @socket_accept($connection)) {
		echo "\nFound new!\n";
		$clients[] = $new;
	}
	foreach ($clients as $v) {
		while ($line = socket_read($v,1024,PHP_NORMAL_READ)) {
			foreach ($clients as $v2) {
				socket_send($v2,$line,strlen($line),MSG_OOB);
			}
		}
	}
	usleep(500);
}
?>

 

the code all works, I've got the following ports forwarded to my computer on the network: 4001 - 4030 and 4005 falls between there so thats the port I'm using to accept connections.. however when I try to CONNECT to this.. I get "target machine actively refused connection":

 

<?php
date_default_timezone_set('America/New_York');
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
socket_connect($socket,'192.168.1.103',4005);
echo $socket."\n";
sleep(300);
?>

 

so.. I have no idea whats wrong with it, ports are forwarded, I have no firewall.. I can HOST game servers, web servers, why not a PHP based server?

Link to comment
https://forums.phpfreaks.com/topic/188690-php-sockets-problem/
Share on other sites

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.