Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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