Currently known server, ip192.168.10.1
, port number 8123
, language C
, communication protocol udp
Note: The server only receives requests from clients with port number 8234
The code below was found online. It can send a successful request, but cannot receive a return value.
You can see with the packet capture tool that every time a request is sent, the port number on my side is dynamic, starting from about 49k, and increasing by 1 for each request.
The port number is incorrect, so the server will naturally not return a value to me.
function udpGet($sendMsg){
$handle = stream_socket_client("udp://192.168.10.1:8123", $errno, $errstr);
if( !$handle ){
die("ERROR: {$errno} - {$errstr}\n");
}
fwrite($handle, $sendMsg."\n");
$result = fread($handle, 1024);
fclose($handle);
return $result;
}
$result = udpGet('Hello World');
echo $result;
How to solve this problem? I checked some information, but did not find a solution.
https://stackoverflow.com/que...
I don’t want to say anything else, I just want to say:
You can use Google to search for this need,
The keyword is also very simple:
UDP communication can only be sent but not returned, TCP should be used