I have a java server running to handle xml requests and send back a response to the sender. It runs on one port for tcp and another for udp. I got the udp version working fine, but I am having problems with the tcp version. Watching the debug output on the java server, I can see that it is receiving the request from the php client and sending the response. However, the php client hangs up when trying to read the response. I'm guessing the problem is in the socket read function because when I comment that part out it executes fine. Also I am not using a while loop for the reading because I know the response is only one line and < 1024 bytes. Code snippet posted below. Any help would be greatly appreciated.
$xml = "<?xml version=\"1.0\"?><test><testval>blah blah blah</testval></test>"; $port = 1234; $address = gethostbyname( "www.mysite.com" ); $socket = socket_create( AF_INET, SOCK_STREAM, getprotobyname( "tcp" ) ); if( $socket == FASLE ) { //error out... } $result = socket_connect( $socket, $address, $port ); if ( $result == FALSE ) { //error out... } if( socket_write( $socket, $xml, strlen ($xml) ) == FALSE ) { //error out... } $response = socket_read( $socket, 1024, PHP_NORMAL_READ ); socket_close($socket); print "<textarea rows=20 cols=200>$response</textarea>"; //now parse the response $p = xml_parser_create(); xml_parser_set_option( $p, XML_OPTION_CASE_FOLDING, 0 ); xml_parser_set_option( $p, XML_OPTION_SKIP_WHITE, 1 ); xml_parse_into_struct( $p, $response, $vals, $index); xml_parser_free( $p ); //this will show you whats in the array print "xml response array: "; print_r( $vals ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php