Questions tagged [setsockopt]

142 questions
5
votes
1 answer

What is the purpose of SO_REUSEADDR?

I am trying to understand a multicast code, and I don't understand the utilities of a little part : int fd_socket = socket(AF_INET, SOCK_DGRAM, 0); u_int yes = 1; setsockopt(fd_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); I don't…
user6125411
5
votes
2 answers

Socket buffer size not increasing

int n = 0; if ( 0 != getsockopt(iSockFd,SOL_SOCKET,SO_RCVBUF, &n, sizeof(n))) { printf("Get socket option failed, errno: %d\n",errno); } else { printf("Current socket buff len = %d\n", n); } n = 225280; if(0 != setsockopt(iSockFd,…
pa1
  • 778
  • 3
  • 11
  • 26
5
votes
3 answers

Does Linux raw socket buffer size have upper limit of 256 K?

I am using following code in Centos to change raw socket buffer size to 400 KB, however I got same result as I set buffer size to 256 KB. Anything wrong? or this is the limitation of socket layer? The kernel version is 2.6.34. Thanks! int …
Yan x
  • 71
  • 1
  • 1
  • 6
5
votes
2 answers

Proper use of getsockopt and setsockopt for SO_RCVTIMEO and SO_SNDTIMEO

By various reasons I would like to implement timeout on reading and writing to socket in a server but fail to get it running and therefore kindly ask for some insight into wherein the problem may reside. In order to set the timeout on the read and…
cpaitor
  • 423
  • 1
  • 3
  • 16
5
votes
1 answer

what is parameter level in getsockopt?

I got the following link: SOL_SOCKET in getsockopt() But it is really confusing for me. One replied that the SOL_SOCKET means the socket layer. What is the socket layer? Are there any other options available for that parameter? What happens if we…
VINOTH ENERGETIC
  • 1,775
  • 4
  • 23
  • 38
4
votes
1 answer

How to change TCP Congestion Control algorithm using setsockopt() call from C++ code

Is it possible to change TCP congestion control algorithm from Cubic to Reno or vice versa using setsockopt call from C++ code in linux? I am looking for an example code of doing so.
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
4
votes
5 answers

Duplicate packets in Multicast Receiver Socket

There seems to be a bug in the following MulticastReceiver implementation. On creating two instances for <224.0.25.46,13001> and <224.0.25.172,13001>, I get each packet twice in each stream. Any pointers ? My guess is REUSEADDR ? class…
Humble Debugger
  • 4,439
  • 11
  • 39
  • 56
4
votes
1 answer

Is there a way to reduce the minimum lower limit of the socket send buffer size?

I'm trying to change the default socket send buffer size to a small size, in order to see how the UDP throughput gets affected for small UDP datagrams. To do this, I use the setsockopt function with the option SO_SNDBUF and I am trying to set the…
Thanasis Petsas
  • 4,378
  • 5
  • 31
  • 57
4
votes
2 answers

getsockopt SO_RECVBUF after doing a set shows double the value in linux?

When calling setsockopt with SO_RECVBUF, then turning around and calling getsockopt with SO_RECVBUF, it appears to be telling me that it sets the buffer size to twice what I requested it to be set to. Anybody know why that may be? code in…
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
4
votes
2 answers

IP_ADD_MEMBERSHIP on a socket, will the socket listen to unicast also?

Considering the code below, I'm trying to bind a UDP socket for multicast. I've bound it to a specific port, and set IP_ADD_MEMBERSHIP for the address to listen to. My question: will the socket receive unicast UDP packets bound for that port? If so,…
Yarel
  • 424
  • 1
  • 6
  • 15
4
votes
3 answers

See socket options on existing sockets created by other apps?

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)…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
4
votes
1 answer

getsockopt returns different IP_TOS value from the one set in setsockopt

I'm trying to use setsockopt to set IPTOS value to IPTOS_THROUGHPUT. The setsockopt call returned 0. However the getsockopt shows the IP_TOS value is set to 1, which is different from IPTOS_THROUGHPUT (0x8). Does anyone have idea what could have…
Fei Wan
  • 43
  • 1
  • 3
4
votes
1 answer

SO_REUSEADDR with UDP sockets on Linux. Is it necessary?

My UDP socket is bind()ing to port 53 (DNS). Does UDP have a TIME_WAIT state or is using SO_REUSEADDR pointless on UDP sockets?
dongle26
  • 826
  • 1
  • 10
  • 18
3
votes
1 answer

How to stop Undertow triggering warnings from gVisor in Cloud Run

Recently my Undertow application is triggering Cloud Run to report the following: Container Sandbox Limitation: Unsupported syscall setsockopt(0x13,0x1,0xa,0x3e05747fe5a0,0x4,0xfc1abc10). Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt…
mgenereu
  • 33
  • 3
3
votes
1 answer

Why is UDP Multicast Server not responding?

I am trying to implement basic UDP multicast client and server on Linux. The server, based on a message sent by the client, is supposed to reply with system parameters (kinda like SNMP). Right now, I am testing with a single server. After running…
psk1993
  • 33
  • 5
1
2
3
9 10