Answer the question
In order to leave comments, you need to log in
How to transfer data from the server to the program?
Hello. There was a need to transfer data from the site to the computer. I came up with the idea to write a simple software in Delphi, in which there will be a tcp server, and data will be sent from the site by a socket. But something goes wrong, or I'm doing something fundamentally wrong. In delphi, I throw the TcpServer component, specify the port 80, immediately make it Active: true, and in order to understand that the server received some data on the TcpServer1Accept event, I simply hang up showmessage ('hallo');
On the php side, I took an example from php.net
$fp = stream_socket_client("tcp://128.75.114.10: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);
}
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = "Пинг !";
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0, '128.75.114.10', 80);
socket_close($sock);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question