Understanding of socket accept function by network programming in Python

Source: Internet
Author: User

On the server side, socket () returns the socket for listening (listen) and accept, which cannot be used to send and receive data between clients.

Accept () accepts a connection request from a client and returns a new socket that differs from the socket () that is returned by the socket () to listen for and accept the connection request from the client, which is done by sending and receiving data on this new socket.

Each incoming client, through the Accept function, returns a different client socket object and a socket that belongs to the client, and the code

Assuming a total of 3 clients connected to the server side, then on the server side of the move has 4 sockets, the 1th is the socket () returned, the socket for listening, and the other 3 are called 3 times respectively accept () the different sockets returned.

If you already have a client connected to the server side and you no longer need to listen and accept more client connections, you can close the socket returned by the socket () without affecting communication with the client.

Understanding of socket accept function by network programming in Python

Related Article

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.