View Single Post
Old 01-19-2013, 10:06 PM   PM User | #1
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
Use same socket to communicate

Hello guys. I made this code to send commands to another machine. But every time i wanna send a command it creates a new socket to do that. Whats the best way to use the same socket to communicate?

PHP Code:
<?php
    
if ($_POST){
        
$sock socket_create(AF_INETSOCK_STREAM0);
        
socket_connect($sock"127.0.0.1"6000);
        
socket_send($sock$_POST["command"], strlen($_POST["command"]), 0);
    }
?>
<form action="message.php" method="post">
    <input type="text" name="command"/><input type="submit"/>
</form>
sorlaker is offline   Reply With Quote