Sigpipe:
Write socketProgramIf you try to send to a disconnected socket, the underlying layer will throw a sigpipe signal.The default processing method for this signal is to exit the process, which is not what we expect most of the time. Therefore,
Client Side
server side
(1) invokes shutdown (S, sd_send) to signal end of session and that client has no more data to send.
(2) es fd_close, indicating graceful shutdown in progress and that all data
The close () function is called when a TCP connection is disconnected in Linux. There are two methods: elegant disconnection and forced disconnection.
So how do I set the disconnection mode? Is to set a linger struct attribute of the socket
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
Int setsockopt (Socket s,Int level,Int optname,Const char * optval,Int optlen);
S (socket): point to an open set Interface DescriptionLevel: (level): Specifies the option code type.Sol_socket: basic set of interfacesIpproto_ip: IPv4 InterfaceIpproto_
The user interface for the Linux socket. This BSD-compatible socket is a unified interface between the user process and the Kernel network protocol stack, each protocol module belonging to a different protocol family, such as Pf_inet, Pf_ipx,
SetSockOpt Method
[CPP]View Plain copy print? #include
intSetSockOpt (
intSocket
intLevel
intOption_name,
Const
void*option_value,
size_tOption_len);
The first parameter socket is a socket descriptor.
The second parameter level is the levels of the
This is the first of a series of articles on how to develop Web programs for Linux using a variety of available interfaces. Like most unix-based operating systems, Linux supports the use of TCP/IP as a local network transport protocol. In this
This is the first of a series of articles on how to develop Web programs for Linux using a variety of available interfaces. Like most unix-based operating systems, Linux supports the use of TCP/IP as a local network transport protocol. In this
Second, used to get and set Socket Options for Getter and the Setter MethodThe socket selection lets you specify how the socket class sends and accepts data. In JDK1.4 there are 8 socket options that can be set. All 8 of these options are defined in
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.