public static function WebSocket($port) { $address = SERVER_IP; if (DEBUG) { echo "WebSocket\n"; } $master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or connection::logdie("socket_create() failed"); socket_set_option($master, SOL_SOCKET, SO_REUSEADDR, 1) or connection::logdie("socket_option() failed"); socket_bind($master, $address, $port) or connection::logdie("socket_bind() failed"); socket_listen($master, 20) or connection::logdie("socket_listen() failed"); connection::logm("Server Started : " . date("Y-m-d H:i:s") . "\n"); connection::logm("Master socket : " . $master . "\n"); connection::logm("Listening on : " . $address . ":" . $port . "\n\n"); return $master; }