Jump to content

ytt

New Members
  • Posts

    2
  • Joined

  • Last visited

ytt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Problem occurs as same even if I add \r\n to server's response or set the socket non blocking.
  2. <?php if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } if (socket_connect($sock, '127.0.0.1', 10000) === false) { echo "socket_connect() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } $msg = "test"; socket_write($sock, $msg, strlen($msg)); if (false === ($buf = socket_read($sock, 2048, PHP_NORMAL_READ))) { echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; } echo "response: $buf \n"; I am using this code to connect to a C socket server. Server is functioning without any problems with clients that are written by C. But when I use php client it hangs after 2 attempts at socket_read. First two results are good but after that it hangs at socket_read. What might be the main cause of this behavior I have no idea. Any suggestions ?
×
×
  • 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.