套接字没有绑定

时间:2016-12-24 13:28:01

标签: php sockets wamp

`我正在尝试逐步学习php中的socket编程。但我无法理解为什么我会看到这个错误:

  •  Warning: socket_bind(): unable to bind address [10048]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in D:\wamp\www\pl\mo.php on line 16
    
  • 我曾尝试多次更改端口号但没有用。我一直看到同样的错误。

    set_time_limit(0);
    
    $ip = "127.0.0.1";
    $port = 123;
    
     // set the protocols
         if( !$socket = socket_create(AF_INET,SOCK_STREAM,0) ){
      echo "cant creat socket"    ;
    }
    
    echo "The socket's protocol info was set \n";
    
    // bind the socket
    if( !socket_bind($socket,$ip,$port) ){
    echo "can't bind socket";
    }
    ?>
    

0 个答案:

没有答案