Questions tagged [setsockopt]

142 questions
0
votes
2 answers

Specifying timeout option with setsockopt() results in subsequent listen error

Right now, I am trying to specify options with setsockopt() using the following code: // bind socket // Use setsockopt() function to make sure the port is not in use int yes = 1; setsockopt(TCPSocket, SOL_SOCKET, SO_REUSEADDR, &yes,…
Bobazonski
  • 1,515
  • 5
  • 26
  • 43
0
votes
1 answer

Set TCP Options on an unprivileged socket (not raw) in a Linux C program

Which TCP Options can I set for outgoing TCP packets on unprivileged socket (not raw) in a Linux C program? I refer to TCP Options in TCP Header. I've checked http://linux.die.net/man/7/tcp so for now I can add/edit: MSS, Timestamp, Window Scale,…
the structure
  • 89
  • 1
  • 10
0
votes
2 answers

How to set a socket option in C++ using setsockopt

Still, having troubles with my code. if (argc > 0) { int route (argc);//[argc+1] ((char*) route)[0] = 1; ((char*) route)[1] = 2;//131 ((char*) route)[2] = 3 + argc * 4; ((char*) route)[3] = 4; for (int i = 0; i < argc; i++) { route =…
0
votes
0 answers

caching effects due to SO_BINDTODEVICE in setsockopt

by SO_BINDTODEVICE socket option we could set the socket to one of the network interface , also if we use two NIC cards and if we want to set the socket to one of the NIC card the SO_BINDTODEVICE will help . if we set the socket to eth1 in the…
Siva Kannan
  • 2,237
  • 4
  • 27
  • 39
0
votes
1 answer

set socket buffer size for receive and send buffer

How can I set the socket buffer size for a UNIX socket file descriptor in C? I understand setsockopt is probably the system call involved... Can anyone give an example of how to use it, the one's I have found do not explain how to set the buffer…
tsar2512
  • 2,826
  • 3
  • 33
  • 61
0
votes
1 answer

Set sockopt of QTcpSocket

I am creating a Linux C++/Qt5 app which opens a TCP socket for an outbound connection (to a remote server). I create a QTcpSocket and then try to set sockopt options as follows: m_tcpSocket = new QTcpSocket(this); int fd =…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
2 answers

How to send multicast data from a particular IP?

I am trying to send data to a multicast group from an alias IP added previously to an interface. I am calling setsockopt with IP_MULTICAST_IF and the alias IP. But the data is always sent from the default IP of that interface. For explanation, I am…
JatiA
  • 73
  • 1
  • 4
  • 12
0
votes
1 answer

Why is setsockopt returning EINVAL?

I am trying to add an address to the multicast address list for an interface using the setsockopt function, but it fails with errno EINVAL. I put some printk's in the kernel code and it looks like the errno is ultimately being set in the kernel…
0
votes
1 answer

C UDP sockets: Arbitrary setsockopt behavior (with SO_RCVTIMEO)

SO_RCVTIMEO is simply not creating a timeout condition in my output functions. I'm designing a file transfer service using a ARQ Sliding Window protocol. To keep things orderly, I'm starting with basic Stop-and-Wait. This is my initialization of…
Regress.arg
  • 352
  • 6
  • 16
0
votes
1 answer

How do I re-bind a socket in MacOSX/Ubuntu? A second time

I have the following code: if ( ( m_mainSocket = ::socket( PF_INET, SOCK_STREAM, IPPROTO_TCP ) ) < 0 ) { throw Exception( __FILE__, __LINE__ ) << "Unable to create socket"; } int on( 0 ); if ( setsockopt( m_mainSocket, SOL_SOCKET,…
Wagner Patriota
  • 5,494
  • 26
  • 49
0
votes
1 answer

How to detect dead client with keepalive option enabled

As I have mentioned in the title, I am using keepalive options to detect dead client on server side. The code snippet that enables keepalive, on the connected tcp socket, looks alike as below. Other options which manipulates keepalive behaviour like…
Yogesh R.L
  • 609
  • 7
  • 17
0
votes
1 answer

Not able to set IP_TTLand IP_TOS Setsockopt

I have defined an UDP socket #include #include sockaddr_in faraddr; memset(&faraddr, 0, sizeof(sockaddr_in)); unsigned short Port = 6789; faraddr.sin_family = AF_INET; faraddr.sin_port …
Euler
  • 652
  • 3
  • 11
  • 24
0
votes
2 answers

Can I set SO_RCVBUF to 1 on a UDP socket

I have a system where a single-byte message is sent via a UDP socket from one process to another when something happens. On the receiving end, it matters not if this event has happened once or a dozen or even a million times. Rather than making…
John Hascall
  • 9,176
  • 6
  • 48
  • 72
0
votes
1 answer

setsockopt error WSAEADDRNOTAVAIL

Source: WSADATA WSAData; SOCKET sock; if (WSAStartup(MAKEWORD(2,2), &WSAData)!=0) { printf("\nProblem with WSAStartup\n\n"); return FALSE; } if ((sock = WSASocket(AF_INET,SOCK_RAW,IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED)) == INVALID_SOCKET)…
Ian
  • 218
  • 3
  • 11
0
votes
1 answer

read() with setsockopt() in C

I'm trying to write a server-client code and I'm stuck at a point. I want the client to read for a certain amount of time and timeout. I tried using setsockopt() with SO_RCVTIMEO specifying the time in timeval struct, but my read() doesn't wait for…
Rich
  • 21
  • 2
  • 6
1 2 3
9
10