Use mac to implement php socket development, but directly lose it in socket -- blind.

Source: Internet
Author: User
The related code is as follows: $ socketsocket_create (AF_INET, SOCK_STREAM, $ commonProtocol) ordie (& quot; cannotcreatesocketn & quot;); bind the socket to the port $ resultsocket_bind ($ socket, $ host, $ port) ordie (& quot; cannotbindporttosocketn & quot;); start to listen to this port $ resultsocket_listen ($ so socketphp

The related code is as follows: $ socket = socket_create (AF_INET, SOCK_STREAM, $ commonProtocol)

Or die ("cannot create socket \ n"); // bind the socket to the port $ result = socket_bind ($ socket, $ host, $ port) or die ("cannot bind port to socket \ n"); // start listening to this port $ result = socket_listen ($ socket, 4) or die ("cocould not set up socket listen \ n"); // accept the connection, and the other socket handles the communication $ msgsock = socket_accept ($ socket) or die ("cannot accept incoming connection \ n"); if ($ msgsock) {echo date ("Y-m-d H: I: s D ");} // read the information sent from the client $ input = socket_read ($ msgsock, 1024) or die ("cannot read input \ n"); $ input = trim ($ input ); $ output = strrev ($ input ). "The order is reversed \ n"; // process the received information and return it to the client socket_write ($ msgsock, $ output, strlen ($ output )) or die ("cannot write"); // Close the socket connection socket_close ($ msgsock); socket_close ($ socket );

The cannot bind port to socket is displayed on the webpage!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.