Getting Started with PHP network programming

Source: Internet
Author: User
Tags getting started with php
This article introduces you to the Code of PHP network programming, interested friends can see

<?php//echo gethostbyname ("www.baidu.com"); $host = "111.13.100.92";   Set basic information $port = 65530;             Set_time_limit (0);         Set timeout time//create a socket$socket = Socket_create (af_inet,sock_stream,0) or die ("Cannot establish socket link! \ n ");//bind socket to port $result = Socket_bind ($socket, $host, $port) or Die (" cannot bind socket given port \ n ");//start listening $result = socket_ Listen ($socket, 3) or Die ("failed to establish socket connection \ n"),//Accept connection request, another socket processing communication $socket_a = Socket_accept ($socket) or Die (" Cannot accept client socket request \ n ");//Get client input Request $input = Socket_read ($socket _a,4096) or Die (" read client input failed \ n ");//Empty input character $input = Trim ($ Input),//process the client input and process the result $output = Strrev ($input). " \ n "; Socket_write ($socket _a, $output, strlen ($output)) or Die (" cannot return results to client \ n ");//Close Socketsocket_close ($socket _a); Socket_close ($socket);? >

Related recommendations:

PHP tips for Getting Started page value analysis

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.