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