Innovation begins with imitation! The built-in socket module in python simplifies network programming. Next we will use two small scripts to understand how the client establishes a socket with the server. Client code: # clietn. pyif _ name _ = '_ main _': # determine whether to call itself, if not, _ name _ is the script name import socket # import the required socket module sock = socket. socket (socket. AF_INET, socket. SOCK_STREAM) # The first step
1 Communication
Program Generally, the Client/Server format is used. This requires that the server host can process requests from multiple clients at the same time. Therefore, you must add multiple Winsock Controls when writing server programs. At the beginning, we first add two Winsock Controls. One of them is used to listen to the online request signal, named listener; the other is the initial connection interface, named sock (
0 ). Note that the
ProFTPD1.3.0/1.3.0a (mod_ctrlssupport) LocalBufferOverflowExploit vulnerability and attack code analysis (leave a pitfall for future tracking)
Attack code URL: http://www.exploit-db.com/exploits/3330/
1. Running environment:1. ProFTPD 1.3.0/1.3.0a2. When compiling ProFTPD, The -- enable-ctrls option must be enabled../Configure -- enable-ctrls3. The local user must have the permission to connect through a Unix Socket.2. running parameters:Revenge @ darklight ~ $./Revenge_proftpd_ctrls_24.pl/usr/
third parameter specifies the corresponding transport protocol, such as TCP/UDP, which is generally set to 0来 using this default value.
int sock = socket (af_inet, sock_stream, 0);
if (sock = = 1) {Close
(sock);
NSLog (@ "Socket error:%d", sock);
2, bind this machine address and port number
Address stru
: BSD socket is an interface that can be used for various network protocols. When it is used for TCP/IP, that is, a socket in the af_inet format is created, additional parameters need to be retained, so there is the struct sock structure.Files mainly include:/NET/IPv4/protocol. C/NET/IPv4/af_inet.c/NET/CORE/sock. c etc
. TCP/UDP layer: process the operation on the transport layer. The transport layer is rep
other signals to be processed and then smooth exit.
1.2 Listener and worker processes
Since all listener and workers are child processes of the master process and have the 1+5+2 sock created by master, the first thing to do when the Lisener and worker processes start is to tell the kernel what you need to be concerned about sock, is placed in the Epoll.
We will find that this picture is not the same a
, how they do?They use this thing. This thing is called flight progress strip. Each block represents a flight, different slots represent different states, and then an air operator is able to manage a set of such blocks (a set of flights) while he works. is when there is a new update on the flight information. Put the corresponding blocks into different trough.This thing has not been eliminated now oh, just become electr
Service-side (server)#include #include#pragmaComment (lib, "Ws2_32.lib")//Add the Ws2_32.lib to the link library on the links page#definePORT 15001//Port of communication (referred to as server side)#defineERROR 0#defineBuffer_size 1024//Note: This server-side data receive buffer >= the client-side data send buffer, which otherwise causes a buffer overflow/*Service-side principle: 1, the server process to create socket 2, bind the local address to the created socket, to ternary group {*/intMain
图片描述](https://pic2.zhimg.com/583d5ba3cee12e78befa8e2b749f4269_b.jpg)This thing is called flight progress strip. Each block represents a flight, different slots represent different states, and then an air operator can manage a set of such blocks (a set of flights), and his job is to put the corresponding blocks into different trough when the flight information is updated.This thing has not been eliminated now oh, just into the electronic.Do you feel that a lot of efficiency is high, an empty tube
) function to retrieve the pointer for use, however, it seems that exosip does not use it, but it may be left for personal extension :) We can also see the sock initialization code on the Win32 platform before the initialization code. We can know that exosip is a native Winsock API function, that is, when we used to write sock programs using VC and winapi (instead of MFC), we used the
7. UDP
In the most common sense, the so-called UDP is a network protocol that does not matter when it is sent out. Therefore, the sending end of UDP programming only needs to send, and the network connection status does not need to be checked. The following example describes how to write UDP and describes each API and Data Type in detail.7.1 UDP broadcast sending program
The following is an example of using UDP to send broadcast packets.
# Include
# Include
Void main ()
{
Socket
writeData Method for sending data, as defined below-(void) writeData :( NSData *) data withTimeout :( NSTimeInterval) timeout tag :( long) tag; the following is an instance statement. NSData * aData = [@ "test data" dataUsingEncoding: NSUTF8StringEncoding]; [sock writeData: aData withTimeout:-1 tag: 1]; function overload in onSocket, for example, the definition is specifically used to process the data sent by the SOCKET :- (Void) onSocket (AsyncSocke
monitored file descriptors changes. Second, if the time value is set to 0 s and 0 ms, it becomes a pure non-blocking function. no matter whether the file descriptor has changed or not, it immediately returns to continue execution. If the file does not change, 0 is returned, and a positive value is returned. Third, the value of timeout is greater than 0, this is the waiting timeout time, that is, the SELECT statement is blocked within the timeout time, and an event will be returned within the ti
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.