Previous article, Linux interprocess communication--using flow sockets to introduce some basic content about sockets (sockets), and to explain the use of the flow sockets, this article will tell you, the use of datagram sockets.a simple review-what
1 UDP Receive principleThe UDP receiving process of the operating system is as follows: After receiving a UDP packet, after verifying that there is no error, put in a package queue, each element in the queue is a complete UDP packet. When the
Send functionint send (SOCKET s, const char far *buf, int len, int flags);Both the client and the server application use the Send function to send data to the other end of the TCP connection.The client program typically sends a request to the server
Send function
int send (SOCKET s, const char FAR *buf, int len, int flags);
Both the client and the server application use the Send function to send data to the other end of the TCP connection.
The client typically sends a request to the server
Send Function
Int send (socket S, const char far * Buf, int Len, int flags );
Both the client and server applications use the send function to send data to one end of the TCP connection.
The client program generally uses the send function to send
Send Function
Int send (socket S, const char far * Buf, int Len, int flags );
Both the client and server applications use the send function to send data to one end of the TCP connection.
The client program generally uses the send function to send
The timer and recvfrom functions are required to collect broadcast information in the 5 s cycle. In the practical process, it is found that the program is still in the blocking status, I have been struggling for a long time before I find the problem.
Both Recv and recvfrom are used to accept data from the network. Let's take a look at their prototype:
Int Recv (Socket{Function onclick (){Function onclick (){Showtip (this)}}} "> S,Char far*{Function onclick (){Function onclick (){Showtip (this)}
[Recv/recvfrom/recvmsg System Call] function description:
Receives a message from a socket. For recvfrom and recvmsg, it can be applied to connection-oriented and connectionless sockets at the same time. Generally, Recv is only used in
Phenomenon:On a Windows 7 system, a uses a UDP socket, which calls the SendTo function to send data to a destination address B, but the destination address B does not receive data, and if a immediately calls Recvfrom to attempt to receive the data
偶然情况下recvfrom函数出现了不正常的情况,目前还没有复现。
Post part of the code and the information in the log price.
struct timeval tv_out;tv_out.tv_sec = 120;tv_out.tv_usec = 0;setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv_out, sizeof(tv_out)); udp_media_
A typical function Call of UDP C/sUDP does not have a connection like TCP, the client directly sendto to a server to send data, the server side has been recvfrom blocked to receive any client-sent data.Second, sendto and Recvfrom functionsint sendto
1. Typical UDP client/server communication process
Following the communication process, we will implement a UDP redirection Client/Server.
# Include # Include
Ssize_t send (INT sockfd, const void * Buf, size_t Len, int flags );
Ssize_t sendto
1. Block I/O2. Non-blocking I/O3. I/O multiplexing (select and poll)4. Signal-driven I/O (sigio)5. asynchronous I/O (posix.1 AIO _ series functions)
An input operation in UNIX generally has two different stages:1. Wait for the data to be ready.2.
ReferenceRichard Stevens's"UNIX Network Programming Volume 1, third edition: The sockets networking".
Steven s proposed a total of five Io models:
Blocking Io
Nonblocking Io
Io multiplexing (select and poll)
Signal driven io
Five Basic I/O models in UNIX:
1. Block I/O2. Non-blocking I/O3. I/O multiplexing (select and poll)4. Signal-driven I/O (sigio)5. asynchronous I/O (posix.1 AIO _ series functions)
An input operation in UNIX generally has two different stages:1.
Generalized synchronous/asynchronous, blocking/ non-blocking
Synchronous vs Asynchronous (synchronous vs asynchronous)
A message communication mechanism that synchronizes and asynchronously concerns.
Synchronization and Asynchrony are just the
I/O model
Five I/O models available in UNIX:
(1) blocking I/O
(2) non-blocking I/O
(3) I/O multiplexing (select and poll)
(4) signal-driven I/O (SIGIO)
(5) asynchronous I/O
For input operations on a set of interfaces, the first step usually
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.