Questions tagged [setsockopt]

142 questions
3
votes
1 answer

How to efficiently pass an argument, just very occasionally met, to a child thread?

I'd like to pass a string argument to a child thread ( that is continuously reading a socket ) and call a setsockopt() with that argument on that socket. I'm using ZeroMQ sockets, so calling setsockopt() is not threadsafe here, I'd call the…
janos_dfc
  • 87
  • 1
  • 5
3
votes
0 answers

setsockopt() returns EBUSY

I have just succesfully opened a RAW socket and I am trying to export Kernel TX and RX rings with the function below. However, setsockopt() returns EBUSY (Device or resource busy) when trying to tell the kernel to export the SECOND of the rings.…
nsx
  • 697
  • 1
  • 13
  • 41
3
votes
1 answer

setsockopt on "accepted" fd on Linux

I have had a rather strange observation about behavior of setsockopt on Linux for SO_REUSEADDR. In one line: if I apply the sockopt to an fd returned by accept on a "listening socket" the socketoption is reflected on the port held by the listening…
Saurabh
  • 1,059
  • 10
  • 20
3
votes
2 answers

Invalid argument in sendto when using interface name to set IP_MULTICAST_IF

I am writing a small program that sends and receive multicast packets.I need to set the outgoing interface with its name (e.g. eth0) rather than its address. Therefore I have to use struct ip_mreqn (rather than struct in_addr) so that I could use…
Jahanzeb Farooq
  • 1,948
  • 4
  • 27
  • 27
2
votes
2 answers

How do I set `SO_RCVTIMEO` on a socket in Perl?

If I try like this: my $sock = IO::Socket::INET->new( … ) or die "no socket for you"; defined $sock->setsockopt(SOL_SOCKET, SO_RCVTIMEO, 30) or die "setsockopt: $!"; then my script suffers death from "setsockopt: Invalid…
derobert
  • 49,731
  • 15
  • 94
  • 124
2
votes
2 answers

Is windows's setsockopt broken?

I want to be able to reuse some ports, and that's why I'm using setsockopt on my sockets, with the following code: sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) However, this doesn't really work. I'm not getting a bind error either, but…
Geo
  • 93,257
  • 117
  • 344
  • 520
2
votes
1 answer

What do socket.SOL_SOCKET and socket.SO_REUSEADDR in Python

Thank you for reading this, I appreciate any help! I don't really seem to find an answer that satisfies the following questions, mostly explained unclearly. Imagine I'd create a socket object in Python: socket = socket.socket(socket.AF_INET,…
2
votes
1 answer

Join multicast group on DatagramSocket?

I want to receive network data multicasted by another application on an AIR UDP socket (DatagramSocket). In other programming languages, this is achieved by calling (Java) "sock.joinMulticastGroup(group)". In C it is a simple "setsockopt" call. I…
2
votes
0 answers

Is socket option SO_KEEPALIVE supported for unix domain sockets (socket family AF_UNIX)?

In our program, communication is happening over unix domain socket. When socket is created we are enabling socket option SO_KEEPALIVE on the socket. Call to setsockopt() is successful but netstats output doesn't so it. Output is as follows. tcp …
2
votes
0 answers

Is it possible to set socket options for a UDP socket a different process other than the process that created the same?

I have created a UDP socket via process A. However my process A does not have root access to set socket options using the setsockopt api from linux to bind it with the broadcast IP (255.255.255.255). So I have created another process B with root…
Arjun Sanu
  • 21
  • 2
2
votes
0 answers

Setting DSCP on a per-socket base

There are several examples about using iptable to set the DSCP field of the the IP packets. I am trying not to use iptables, but to set the DSCP field just on a few selected sockets. By reading man 7 ip, I found out that I can use something link int…
Ottavio Campana
  • 4,088
  • 5
  • 31
  • 58
2
votes
1 answer

Enabling UDP packet timestamps on macOS with SCM_TIMESTAMP

I tried to enable hardware UDP packet timestamps on macOS (and iOS) and have trouble getting it to work (working on macOS 10.13.4, Xcode 9.3). My goal is to get as precise as possible timestamps for outgoing and incoming UDP packets, ideally…
Felix
  • 21
  • 3
2
votes
1 answer

How to set socket option IP_DONTFRAG in python?

How can I set DONT_FRAGMENT flag in IP header using python sockets? The following code socket.setsockopt(socket.IPPROTO_IP, socket.IP_DONTFRAG, 1) gives me this error: AttributeError: 'module' object has no attribute 'IP_DONTFRAG' Anyone has an…
2
votes
0 answers

SO_SNDBUF and SO_RCVBUF

Is setsockopt with SO_SNDBUF and SO_RCVBUF needed for the application to avail maximum TCP buffer limits? I have a 1Gbps network with a delay of 100ms between my hosts and I am trying to pump data at full speed between them using my custom client…
Aparna Chaganti
  • 599
  • 2
  • 5
  • 15
2
votes
1 answer

setting setsockopt for detect ip option

i want to detect ip options of incoming internet packets. Here's my code. //#define IPPROTO_IP 0 //#define IP_OPTIONS 68 #define SENDER_PORT_NUM 53 #define SENDER_IP_ADDR "127.0.0.1" #define true 1 static void bail(const char *error) { …
1 2
3
9 10