Seems possible not impossible. I have not done this before, but I know how to do it, but again I do not know how the firewall affects the opening and closing of the port. The basic idea of ββwhat to do:
Receive a request from port 80 to do something, and to respond to this request, use a different port to communicate with the client. This will become a tunnel to receive a request from one port and receive a response from another port. Only one thing that should be properly taken care of this termination of the connection as soon as possible, when the goal is resolved, unless it creates a memory load on the server.
In the example below, you can do all of the above, but suggest using them with caution and after proper testing.
ref: Programming with Sockets via PHP
This example shows a simple talkback server. Change the address and port settings according to your settings and execute. Then you can connect to the server using a command similar to: telnet 192.168.1.53 10000 (where the address and port correspond to your setting). Everything that you type will be displayed on the server side and will be repeated back to you. To disconnect, enter "quit".
<?php error_reporting(E_ALL); echo "<h2>TCP/IP Connection</h2>\n"; $service_port = getservbyname('www', 'tcp'); $address = gethostbyname('www.example.com'); $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } else { echo "OK.\n"; } echo "Attempting to connect to '$address' on port '$service_port'..."; $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { echo "OK.\n"; } $in = "HEAD / HTTP/1.1\r\n"; $in .= "Host: www.example.com\r\n"; $in .= "Connection: Close\r\n\r\n"; $out = ''; echo "Sending HTTP HEAD request..."; socket_write($socket, $in, strlen($in)); echo "OK.\n"; echo "Reading response:\n\n"; while ($out = socket_read($socket, 2048)) { echo $out; } echo "Closing socket..."; socket_close($socket); echo "OK.\n\n"; ?>
source share