glenelkins Posted October 2, 2007 Share Posted October 2, 2007 Hi I have a script called "server.php" . This is just a basic test script for now with the following code: <?php // Create the socket $socket = socket_create ( AF_INET, SOCK_STREAM, SOL_TCP); // Bind the socket to the localhost socket_bind ( $socket, 'localhost', 1337 ); // Listen for connections socket_listen ( $socket ); // accept any incoming connection and write to the socket. while( $connection = socket_accept( $socket ) ){ // Write welcome message to the socket socket_write($connection,'You\'ve successfully connected to my computer!\r\n'); } ?> As you can see it listens for connections on port 1337. Now the issue is, how do I make this script actually run on the server to listen for connections without manually going through the web browser? For example, i telnet to that port and the script should pick it up thanks Quote Link to comment Share on other sites More sharing options...
trq Posted October 2, 2007 Share Posted October 2, 2007 You'll want to execute the script via the command line. $ ./path/to/script.php & Quote Link to comment Share on other sites More sharing options...
glenelkins Posted October 3, 2007 Author Share Posted October 3, 2007 Yes i figured that one! Thanks though there is an issue. It binds fine to the IP i put in there. But when the telnet is connected through, there is no output when there should be: You've successfully connected to my computer! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.