Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Indefinite execution
- set_time_limit (0);
- // IP and port
- $strIp = '94.224.24.109';
- $intPort = 9000;
- // Create a TCP Stream socket
- $resSock = socket_create(AF_INET, SOCK_STREAM, 0);
- // Bind the socket to an address/port
- socket_bind($resSock, $strIp, $intPort) or die('Could not bind to address');
- // Start listening for connections
- socket_listen($resSock);
- while(true) {
- // Accept incoming requests
- $resClient = socket_accept($resSock);
- // Read input from client
- $strMessage = socket_read($resClient, 1024);
- sleep(2);
- // Write some stuff to client
- socket_write($resClient, 'Hello...');
- // Display output
- echo $strMessage;
- }
- // Close the client (child) socket
- socket_close($resClient);
- // Close the master sockets
- socket_close($resSock);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement