Python socket module

Source: Internet
Author: User

A. Socket

TCP is a connection-based protocol, so you must start the server before you use the client to connect to the server.

UDP is not a connection-oriented protocol, so after starting the server, you do not need to establish a connection with the server in advance, you can accept the message directly

Detailed socket Parameters:

Socket method:

Service-side socket function S.bind ()    bind (host, port number) to Socket S.listen ()  Start TCP Listener s.accept ()  Passive Accept TCP Client connection, (blocked) Wait for connection arrival client socket function S.connect ()     actively initializes an extended version of the TCP server Connection S.CONNECT_EX ()  connect () function, returning an error code when an error occurs, rather than throwing an exception to the common-use socket function S.recv ()            receive T CP Data S.send () sends TCP data            S.sendall () sends         TCP data S.recvfrom ()        receives UDP data s.sendto ()          sends UDP data s.getpeer Name ()     connects to the remote address of the current socket S.getsockname () The     address of the current socket s.getsockopt ()      returns the parameter of the specified socket s.setsockopt ()      setting the specified set    The parameter S.close () of the socket closes the socket for the           lock socket Method S.setblocking () sets the     blocking and non-blocking mode of the socket S.settimeout ()      sets the timeout period for the blocking socket operation S.gettimeout ()      Gets the timeout time of the blocking socket operation the function of the socket for the file S.fileno () The          file descriptor of the socket S.makefile ()        creates a file associated with the socket

Python socket module

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.