tags:

views:

26

answers:

1

Hi,

I am using PHP socket programming and able to write data to open socket but i have to wait for a long time(or stuck it)for the response or some time getting error like "Maximum execution time of 30 seconds exceeded line number where this code is placed fgets($fp, 128), i have check the server it seems it has sent the response as expected but i am not getting why i m unable to get response.following the code using for socket connection and reading data.

functon scoket_connection() {
      $fp = fsockopen(CLIENT_HOST,CLIENT_PORT, $errno, $errstr);
      fwrite($fp,$packet);
       $msg = fgets($fp, 128);
       fclose($fp)
       return $msg;
}

any idea???

A: 

Is by any chance your client on a different platform than the server? When I say different I mean Windows/Linux/Mac. These each have different line endings. fgets() is supposed to read a line which means it expects to find a certain line ending before it returns anything. If one system is sending for example \n and the other expects \r\n it could cause this problem.

Manos Dilaverakis