Jump to content

Sockets problem


VLxPain

Recommended Posts

my current code:

$host="127.0.0.1";
$port=7777;
$timeout=5;
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
if (!is_resource($sk)) {
    exit("connection fail: ".$errnum." ".$errstr) ;
} else {
    fputs($sk, "idkxd") ;
    $dati="" ;
    while (!feof($sk)) {
        $dati.= fgets($sk, 256);
    }
}
fclose($sk);
echo($dati);

The problem is that when I send data to the server, I never get a response. I do not believe that this is a server side problem as it works through a c# application and as well as when I turn the application off. This is what happens when I do not shut the server off:

1. I run the Server

2. I run the php script

3. Data is sent from PHP

4. Server Responds

5. PHP never gets the response

A slightly different way that it does respond to php:

1. I run the Server

2. I run the php script

3. Data is sent from PHP

4. Server Responds

5. I turn off the server application

6. PHP receives data from the server...

 

Please help, I am kind of new with php sockets.

Link to comment
https://forums.phpfreaks.com/topic/212489-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.