简体   繁体   English

无法执行PHP在线服务器

[英]Cannot execute PHP online server

I want to execute a PHP server on my site. 我想在我的站点上执行一个PHP服务器。 IP address of the site is 31.170.161.16. 该站点的IP地址是31.170.161.16。 The socket is not creating when i execute this code. 我执行此代码时未创建套接字。 Is this the address used for $host or any other? 这是用于$ host或其他地址的地址吗? Please help. 请帮忙。

<?php
    // set ip and port
    $host = "31.170.161.16";
    $port = 4096;

    // don't timeout!
    set_time_limit(0);

    // create socket
    $socket = socket_create(AF_INET, SOCK_STREAM, 0);

    // bind socket to port
    $result = socket_bind($socket, $host, $port);

    // start listening for connections
    $result = socket_listen($socket, 3);

    // accept incoming connections
    // spawn another socket to handle communication
    $spawn = socket_accept($socket) or die("Could not accept incoming connection\n");

    // read client input
    $input = socket_read($spawn, 1024) or die("Could not read input\n");

    // clean up input string
    $input = trim($input);
    echo "Client Message : ".$input."<br />";

    // reverse client input and send back
    $output = strrev($input) ."<br />";
    socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n");

    // close sockets
    socket_close($spawn);
    socket_close($socket);
?>

the host company looks like a free hosting company. 托管公司看起来像一个免费的托管公司。 just because its free that doesn't mean all the php features will be available to you. 仅仅是因为它的免费并不意味着所有的php功能都可以使用。 I recommend signing up with a reputable company instead such as digitalocean.com 我建议注册一个有信誉的公司,例如digitalocean.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM