开发者

socket connection issue+php

开发者 https://www.devze.com 2022-12-25 05:08 出处:网络
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 s

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号