回复 5楼 吹水佬
是MSWINSOCK的函数
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
是不是要设置缓存大小?但设置不了,是不是下面API写不对
DECLARE LONG
setsockopt IN "Ws2_32" long s ,long level,long optname ,long optval ,long optlen
&&"wsock32.dll"
DECLARE LONG
getsockopt IN "Ws2_32" long s ,long level,long optname ,long @optval ,long optlen&&"wsock32.dll"
#define
SOL_SOCKET
65535
#define SO_REUSEADDR 0x0004
#define SO_REUSEPORT 15
getsockopt(Thisform.tcpClient.OBJECT.SocketHandle, SOL_SOCKET, SO_REUSEADDR, 1, 1)
setsockopt(Thisform.tcpClient.OBJECT.SocketHandle, SOL_SOCKET, SO_REUSEADDR, 1, 1)
C语言使用如下
*!*
int on = 1;
*!*
setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
为了解决Address in use C:\Windows\SysWOW64\mswinsck.ocx
#define SOL_SOCKET
1
#define SO_DEBUG
1
#define SO_REUSEADDR
2
#define SO_TYPE
3
#define SO_ERROR
4
#define SO_DONTROUTE
5
#define SO_BROADCAST
6
#define SO_SNDBUF
7
#define SO_RCVBUF
8
#define SO_SNDBUFFORCE
32
#define SO_RCVBUFFORCE
33
#define SO_KEEPALIVE
9
#define SO_OOBINLINE
10
#define SO_NO_CHECK
11
#define SO_PRIORITY
12
#define SO_LINGER
13
#define SO_BSDCOMPAT
14
buflen = 65536*10;
设置读缓存大小
setsockopt(m_sendUdpSock,SOL_SOCKET,SO_RCVBUF,&buflen,4)
设置写缓存大小
setsockopt(m_sendUdpSock,SOL_SOCKET,SO_SNDBUF,&buflen,4)
getsockopt(g_sendUdpSock,SOL_SOCKET,SO_RCVBUF,&buflen,&getnumlen)
[此贴子已经被作者于2023-8-28 10:03编辑过]