Awesome q2a theme

How to organize the download of data via TCP?

0 like 0 dislike
36 views
Hello! Can you tell what I'm doing wrong.
There is a device which transmits data via com port! These data must be taken and transmitted to the WEB server for further processing and loading into the database.
Accept data and send to the server but on the server side, something goes wrong.
Opened on the web server(UBUNTU) port 10000 command
 iptables -A INPUT-i eth0 -p tcp —dport 10000-j ACCEPT

Turned off the firewall on the server.
On one of the pages application Yii2 put in code
$address = '192.168.1.180'; $port = 10 000; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_connect($socket, $address, $port); socket_write($socket, "GET / HTTP/1.0\\\\"); $result = "; while($read = socket_read($socket, 1024)) { $result .= $read; } socket_close($socket); echo "the result: $result\\";


But it turns out error
PHP Warning – yii\\base\\ErrorException socket_connect(): unable to connect [111]: Connection refused

If I put port 80. there are no errors.
Can you explain those who are engaged in such problems, how to organize?
by | 36 views

1 Answer

0 like 0 dislike
Look at the socket_listen function.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
110,608 questions
257,187 answers
0 comments
40,796 users