Do not know the socket and TCP connection process, do not know the sockettcp connection
Directory:1. Background2. Detailed connection Process Analysis2.1 socket () function2.2 bind () function2.3 listen () and connect () Functions2.3.1 in-depth
1. Reuse Socket Address:#-*-Coding:utf-8-*-# If you run a Python socket server on a port and then terminate the connection once, you cannot use this port.#!usr/bin/env Python# Python Network Programming Cookbook--chapter-1# Optimized for Python 2.7#
I. Construct a socket
The socket constructor has the following methods:
(1) socket ()
(2) socket (inetaddress address, int port) throws unknownhostexception, ioexception
(3) socket (inetaddress address, int port, inetaddress localaddr, int
Socket (socket)
First look at the definition:
typedef unsigned int u_int;
typedef u_int SOCKET;
Socket is equivalent to the network communication at both ends of the socket, as long as the other side of the socket and their sockets have a
This article refers to the first chapter of Python network programmingImport socketHelp (socket)Functions:Socket ()--Create a new socket objectSocketpair ()--Create a pair of new socket objects [*]FROMFD ()--Create a socket object from an open file
Write the socket program in Python and listen to the service on the specified port:Import socketSock = Socket.socket (socket.af_inet, socket. SOCK_STREAM)Port = 8080Sock.bind (("', port)")Sock.listen (1)print ' Listening on port:%s '% portWhile True:
Network IPC: socket, network ipcInter-process network communication: socket API Introduction
Processes running on different computers (connected through the network) communicate with each other ).
A process can be uniquely identified by a process
In many cases, we need to use a fixed IP and port number to communicate, and by default, the client side of the port number is not fixed, by the system automatically allocate idle port number to communicate;
But in many cases, some services to write
Windows socket Extension function and socket Extension function
1. AcceptEx ()
AcceptEx () is used to receive connections asynchronously and obtain the first piece of data sent by the client program.
[Cpp]View plaincopy
BOOL AcceptEx (
_ In _
Introduction to basic socket programming in Python, pythonsocket
In network communication, sockets are almost everywhere. It can be seen as an intermediate software abstraction layer for communications between the application layer and the TCP/IP
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.