How to read php socket connection response? -


following socket connection request , response order.

$socket = socket_create(af_inet, sock_stream, 0); $connection = socket_connect($socket, $host, $port); $md5checksum = md5($msg);  $willwait = 'soap  '. $md5checksum. '  will_wait'."\n"; socket_write($socket,$willwait);                         socket_write($socket,$msg); socket_write($socket,  soapsender::$term_char); sleep(1); $buf = socket_read($socket, 2048); //socket_write($socket,"&\r\n"); echo "$buf\n"; 

please tell me how read response receive after last socket_write request. have been searching answer day have not been able find through google.

thanks lot time.

two functions should used:

stream_set_blocking($socket, true); 

and

stream_get_contents($socket); 

setting block on stream requires return of data before application continue execution of script.

if not set stream block, latency cause php script think there no response, causing not receive data.

also, use stream_get_contents pull socket. grab default full buffer.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -