setsockopt

Error “No such device” in call setsockopt when joining multicast group

喜欢而已 提交于 2019-11-29 17:55:24
问题 I have a code in which send multicast datagrams. A critical piece of code: uint32_t port; int sockfd, err_ip; const uint32_t sizebuff = 65535 - (20 + 8); unsigned char *buff = (unsigned char *) malloc(sizebuff); struct sockaddr_in servaddr, cliaddr; struct in_addr serv_in_addr; struct ip_mreq req; port = str2uint16(cmdsrv->ipport); bzero(buff, (size_t)sizebuff); bzero(&servaddr, sizeof(servaddr)); bzero(&serv_in_addr, sizeof(serv_in_addr)); err_ip = inet_aton(cmdsrv->ipaddr, &serv_in_addr);

See socket options on existing sockets created by other apps?

守給你的承諾、 提交于 2019-11-29 08:09:35
I'd like to test whether particular socket options have been set on an existing socket. Ie, pretty much everything you can see in: #!/usr/bin/env python '''See possible TCP socket options''' import socket sockettypelist = [x for x in dir(socket) if x.startswith('SO_')] sockettypelist.sort() for sockettype in sockettypelist: print sockettype Anyone know how I can see the options on existing sockets, ie those created by other processes? Alas nearly all the documentation I read on Python socket programming is about making new sockets. Unfortunately, nailer's answer only catches the SOL_TCP level

See socket options on existing sockets created by other apps?

旧城冷巷雨未停 提交于 2019-11-28 01:43:37
问题 I'd like to test whether particular socket options have been set on an existing socket. Ie, pretty much everything you can see in: #!/usr/bin/env python '''See possible TCP socket options''' import socket sockettypelist = [x for x in dir(socket) if x.startswith('SO_')] sockettypelist.sort() for sockettype in sockettypelist: print sockettype Anyone know how I can see the options on existing sockets, ie those created by other processes? Alas nearly all the documentation I read on Python socket

Why changing value of SO_RCVBUF doesn't work?

感情迁移 提交于 2019-11-27 14:50:15
I'm making a program which create a RAW socket in order to read all traffic. Between the call of socket() and recvfrom() (last one is in a loop to get out all packets from buffer) I wait 5s. When I run the program, I send about 200 packets with hping3 command in « faster mode » (to fill in the buffer fastly) to my program. As soon as 5s are elapsed, my program extract about 150 packets from the buffer. I try to change the size of the receive buffer to get better result: int a = 65535; if ( (setsockopt(sockfd, 0, SO_RCVBUF, &a ,sizeof(int)) ) < 0 ) { fprintf(stderr, "Error setting sock opts..\n

Why changing value of SO_RCVBUF doesn&#39;t work?

十年热恋 提交于 2019-11-26 14:34:08
问题 I'm making a program which create a RAW socket in order to read all traffic. Between the call of socket() and recvfrom() (last one is in a loop to get out all packets from buffer) I wait 5s. When I run the program, I send about 200 packets with hping3 command in « faster mode » (to fill in the buffer fastly) to my program. As soon as 5s are elapsed, my program extract about 150 packets from the buffer. I try to change the size of the receive buffer to get better result: int a = 65535; if (

What is the meaning of SO_REUSEADDR (setsockopt option) - Linux? [duplicate]

自作多情 提交于 2019-11-26 10:25:52
This question already has an answer here: Socket options SO_REUSEADDR and SO_REUSEPORT, how do they differ? Do they mean the same across all major operating systems? 1 answer From the man page: SO_REUSEADDR Specifies that the rules used in validating addresses supplied to bind() should allow reuse of local addresses, if this is supported by the protocol. This option takes an int value. This is a Boolean option When should I use it? Why does "reuse of local addresses" give? TCP's primary design goal is to allow reliable data communication in the face of packet loss, packet reordering, and — key

What is the meaning of SO_REUSEADDR (setsockopt option) - Linux? [duplicate]

断了今生、忘了曾经 提交于 2019-11-26 02:07:46
问题 This question already has an answer here : How do SO_REUSEADDR and SO_REUSEPORT differ? (1 answer) Closed 6 years ago . From the man page: SO_REUSEADDR Specifies that the rules used in validating addresses supplied to bind() should allow reuse of local addresses, if this is supported by the protocol. This option takes an int value. This is a Boolean option When should I use it? Why does \"reuse of local addresses\" give? 回答1: TCP's primary design goal is to allow reliable data communication

TCP option SO_LINGER (zero) - when it&#39;s required

那年仲夏 提交于 2019-11-26 00:31:00
问题 I think I understand the formal meaning of the option. In some legacy code I\'m handling now, the option is used. The customer complains about RST as response to FIN from its side on connection close from its side. I am not sure I can remove it safely, since I don\'t understand when it should be used. Can you please give an example of when the option would be required? 回答1: The typical reason to set a SO_LINGER timeout of zero is to avoid large numbers of connections sitting in the TIME_WAIT