R
R
Roman Alekseevich2017-04-04 17:11:16
PHP
Roman Alekseevich, 2017-04-04 17:11:16

How to send tcp/xml request to IP from under PHP?

There is an information system. From it in real time it is necessary to get images that go there "it is not known how". The documentation says: connect to port 14074, send tcp / xml requests required: authorization, subscription parameters, and in real time it will give data. The parameters are passed in the form (protocol version is the first thing to be sent to start communication) in response, the server will send . If you connect to PuTTy with the RAW type and send this phrase, then everything works out. In php I try to connect via<proto ver="1.0"/><proto ver="1.0">OK</proto>

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) 
  $result = socket_connect($socket, $address, $port);

connection seems to be, even
$msg = '<proto ver="1.0"/>';
$write=socket_write($socket, $msg, strlen($msg));

returns the size of the sent data. But I start reading - either hangs and timeout, or returns an empty string (well, when, how, because I tried a million parameters and examples from the Internet).

Connecting with
$fp = stream_socket_client("tcp://www.example.com:80", $errno, $errstr, 30); 
if (!$fp) { 
echo "$errstr ($errno)<br />\n"; 
} else { 
fwrite($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\n\r\n"); 
while (!feof($fp)) { 
echo fgets($fp, 1024); 
} 
fclose($fp); 
}

doesn't give any results either. I do not know how to get an answer from this infection!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@smple, 2017-04-04
_

if it is not forbidden in php.ini, you can do it easier if the port is not standard, it is better to use curl

$curl = curl_init('http://nexusdigital.agency/API/....'); 
curl_setopt($curl, CURLOPT_PORT, 81); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 81); 
$result = curl_exec($curl);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question