Questions tagged [setsockopt]
142 questions
1
vote
1 answer
Is the tcp window size relevant to the SND_BUF or RCV_BUF of the tcp socket?
I want to know when I change the SND_BUF of a socket via setsockopt API, will the original window size of the TCP layer be changed accordingly?

ciphor
- 8,018
- 11
- 53
- 70
1
vote
0 answers
LWIP -- using option `SO_BINDTODEVICE` with `lwip_setsockopt()` returns error `ENODEV`
With LWIP, I usually set up my ethernet interface on my embedded device like this (not all argument definitions are specified here):
struct netif gnetif;
// Set up the ethernet interface on embedded device.
netif_add(&gnetif, &ipaddr, &netmask,…

71GA
- 1,132
- 6
- 36
- 69
1
vote
2 answers
setsockopt() returns 10042 error code with winsock.h
I am trying to listen a socket using multicast but it seems that am not using the setsockopt function well. I have been searching the meaning of the error code 10042 and I have found…

Londo
- 157
- 5
1
vote
1 answer
Should the values set with setsockopt stay valid during lifetime of the socket?
I'm trying to create helper functions to setup the keep alive of a tcp socket. The setsockopt function accepts a pointer to a value. My question is, does the value have to stay valid for the entire lifetime of the socket or only while executing this…

Bas Visscher
- 35
- 4
1
vote
1 answer
How do I setsockopt of a TcpStream via libc?
I know TcpStream has stream.set_read_timeout but I need to make it in libc for Windows, but my code don´t works and I believe it is because I can't understand the way to put milliseconds in _value: *const c_char. In Rust I wrote let qtie =…

navetix
- 25
- 4
1
vote
1 answer
Error setsockopt IP_ADD_MEMBERSHIP: No such device
I writting an application that should be able to receive IPv4 or IPv6 multicast datagrams on a socket. I wrote a function that enables the reception of multicast datagrams for a socket through setsockopt (see code below). The strange problem that i…

mab0189
- 126
- 12
1
vote
1 answer
What is the predictable behavior of changing SOL_SOCKET, SO_RCVBUF on the fly on a UDP socket?
What should be expected to happen if we resize the input buffer of a UDP server socket on the fly on a Linux system?
setsockopt(sock, SOL_SOCKET, SO_RCVBUF, ...)
I am particularly interested in these questions:
If I shrink below what is currently…

FlorianB
- 2,188
- 18
- 30
1
vote
0 answers
Why are there no scm_timestamping control messages coming up?
My code consists of two programs: a TCP server and a TCP client. The goal of the project is to get timestamping for TCP working. I consulted this piece of linux documentation, and I can't seem to find anything that would indicate that my code…

wojtat
- 11
- 1
1
vote
0 answers
Setting Python GRPC client socket options
I am looking at a way to set socket options in grpc python.
Scenario: I am running a GRPC client on a host with multiple interfaces and routes defined per interface, called VRF (Virtual Routing and Forwarding). My application has to bind to a…

user489023
- 53
- 3
1
vote
2 answers
Socket C - setsockopt timeout do some things before closing
I use setsockopt with SO_RCVTIMEO option to set a timeout on my socket recv function.
It works, but it instantly closes the socket when time is exceeded. I want to send a message before closing, is it possible ?
(My program have to work on Windows…

Silta
- 99
- 8
1
vote
1 answer
How to resolve "setsockopt(3, SOL_SOCKET, SO_MARK, [10], 4) = -1 EPERM" Operation denied for none root users
I got two network interfaces (ethernet and wlan). Now I found a little script on github (https://github.com/Intika-Linux-Firewall/App-Route-Jail) which seems to allow me to route specific applications through the none default gateway to loadbalance…

Dominik S.
- 76
- 1
- 9
1
vote
0 answers
How to modify IP header options for SYN/ACK packets?
To produce packets with extended IP header setsockopt operation can be performed with level SOL_IP and option IP_OPTIONS:
int ipoption=0xbaadf00d;
int sockfd=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
setsockopt(sockfd, SOL_IP, IP_OPTIONS,…

Mikhail Sorokhtin
- 19
- 1
1
vote
2 answers
Why recv returns -1 and errno=EINTR when set SO_RCVTIMEO?
This problem only hapens when socket is set timeout with SO_RCVTIMEO.
recv should block for 3sec. But it returns because of EINTR as soon as another thread starts.
If I run thread t2, recv in thread t1 will return -1 without blocking and sets errno…

zero15
- 13
- 4
1
vote
1 answer
(recv() == 0) means disconnected or timed out? (sockets, Linux&Windows)
I have set a timeout on my blocking socket ..
DWORD to = 1200;
if (setsockopt (soc, SOL_SOCKET, SO_RCVTIMEO, (char *)&to, sizeof(to))) {
...
}
In the case that recv () then returns zero, how can I tell this is link disconnected or read timed…

RichEarle
- 11
- 2
1
vote
1 answer
Why no error when setting socket send/receive buffer size higher than sysctl max?
Why no error when setting socket send/receive buffer size higher than sysctl max (as I have demonstrated below)? is no error the "expected behavior"?
My sysctl values for socket rmem_max and wmem_max are both set to 212992:
net.core.rmem_default =…

Trevor Boyd Smith
- 18,164
- 32
- 127
- 177