1. closesocket (usually does not close immediately and goes through the time_wait process) to continue to reuse the socket:
Bool breuseaddr = true;
Setsockopt (S, sol_socket, so_reuseaddr, (const char *) & breuseaddr, sizeof (bool ));
2. If you
Normal 0 7.8 pt 0 2 false false false MicrosoftInternetExplorer4
Analysis: setsockopt ()
1. If you want to reuse closesocket after a socket in the established State (usually distinguished
getsockopt ()
Briefly:Gets a set of interface options.#include int PASCAL FAR getsockopt (SOCKET s, int level, int optname,Char far* optval, int far* optlen);S: A descriptive word that identifies the socket interface.Level: The
1.Closesocket (usually does not close immediately and goes through the time_wait process) and wants to continue to reuse the socket:Bool breuseaddr = true;Setsockopt(S, sol_socket, so_reuseaddr, (const char *) & breuseaddr, sizeof (bool ));
2.If you
Interface prototype:Int Pascal far setsockopt (socket S, int level, int optname, const char far * optval, int optlen );
1. If the socket is already in the established State (usually distinguished by the port number and flag ),Closesocket
1.Closesocket (usually does not close immediately and goes through the time_wait process) and wants to continue to reuse the socket:Bool breuseaddr = true;Setsockopt(S, sol_socket, so_reuseaddr, (const char *) & breuseaddr, sizeof (bool ));
2.If you
Setsockopt sets the socket status
1.Closesocket (usually does not close immediately and goes through the time_wait process) and wants to continue to reuse the socket:Bool breuseaddr = true;Setsockopt(S, sol_socket, so_reuseaddr, (const char *) &
Specific explanations and tests of getsockopt and setsockopt under LinuxNAMEnameGetSockOpt, Setsockopt-get and SET options on socketsGets or sets the options for the socketSynopsisFunction prototypes #include /* See NOTES *
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_
VC ++ uses setsockopt () to control the timeout between recv () and send (). setsockoptrecv
In the send () and recv () processes, sometimes due to network conditions and other reasons, sending and receiving cannot be performed as expected, and
Brief description:Set Interface Options.
# Include
Int Pascal far setsockopt (socket S, int level, int optname,Const char far * optval, int optlen );
S: Specifies the description of a set of interfaces.Level: The level defined by the option.
Target: Create a socket, use setsockopt to set its attribute to the broadcast type, and
This broadcast socket sends a broadcast to the System
Problem: The creation (socket), setting (setsockopt), and binding (BIND) are successful, that is, the
From: http://lydnkj.bokee.com/viewdiary.10417372.html
Getsockopt and setsockopt
Obtain the set Interface Options:
Code:
Int getsockopt (INT sockfd, int level, int optname, void * optval, socklen_t * opteln) sets the set of Interface Options:Int
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_
Getsockopt and setsockopt
Set Interface Options: int getsockopt (INT sockfd, int level, int optname, void * optval, socklen_t * opteln) set Interface Options: int setsockopt (INT sockfd, int level, int optname, const void * optval, socklen_t *
Header files: #include #include Define functions: int setsockopt (int s, int level, int optname, const void * optval, Socklen_toptlen);Function Description:The s:setsockopt () is used to set the socket state specified by the parameter S.Level: The
[]
Setsockopt sets the options associated with a socket.
sock socket to be set
The protocol layer of the level option. For example, the socket layer sol_socket
Option name of the optname operation
optval indicates the buffer containing
The significance of the so_reuseaddr of parameters in the setsockopt of http://www.cnblogs.com/qq78292959/archive/2013/01/18/2865926.html (Turn)1, generally speaking, a port after the release will wait two minutes before being used again,
The system provides a socket buffer size of 8K, which you can set to 64K, especially when streaming live video.
When the socket sends data to send data to the socket buffer, then accept the function and then fetch the data from the buffer, if the
Multicast programming -- Role Summary of setsockopt () Option Parameters
So_rcvtimeo so_sndtimeoSets the network transmission and receipt latency. In the send (), Recv () process, sometimes due to network conditions and other reasons, the sending
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.