Questions tagged [getsockopt]
30 questions
14
votes
1 answer
Dial tcp 127.0.0.1:8500: getsockopt: connection refused in consul
I am getting this error when I am running any "consul members" on consul server and clients. The port is in LISTENING state and I made sure there is no firewall blocking. I get this error when in run the same in the consul client:
Error retrieving…

Preethi Jahnavi
- 187
- 1
- 1
- 10
11
votes
2 answers
SO_ERROR vs. errno
For getting socket syscall (like recv) error, which is better (at performance level) ?
Use the plain old errno
Or use SO_ERROR as getsockopt() optname ?
I think errno (defined to __error() on my system) is faster because it's not a system call. Am…

Félix Faisant
- 191
- 1
- 1
- 11
4
votes
1 answer
OS X getsockopt: no SO_PROTOCOL
OS X doesn't offer the SO_PROTOCOL socket option which allows the caller to "...retrieve the socket type as an integer." (http://linux.die.net/man/7/socket)
In other words the following program builds and works under linux but won't compile under OS…

Mike Schiffman
- 240
- 3
- 9
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
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
getsockopt(...,SO_ORIGINAL_DST,...) occasionally returns client address
I am working on a project that accepts HTTP requests and forwards them onto a destination. We use Linux (2.6.35.14-106.fc14.x86_64) and TPROXY. I'll put in the details below.
The problem I am seeing is that OCCASIONALLY (1 time out of a 1000…

mkilian
- 81
- 1
- 5
3
votes
0 answers
socket option TCP_NODELAY on windows requires 8bit Bool?
Here is my example code (I am sorry it is quite long):
#include "stdafx.h"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include
#include
typedef BOOL OPT_TYPE;
int _tmain(int argc, _TCHAR* argv[])
{
…

kuga
- 1,483
- 1
- 17
- 38
3
votes
1 answer
NGINX : Exceeds 65535 connections limit
Unlike HTTP, websocket keeps a long-live connection after it is upgraded from HTTP.
Even if the OS is tuned to use all ports, still there are only 65536 ports in total. Is it possible for NGINX to exceed this limit?
A potential solution is…

Mr.Wang from Next Door
- 13,670
- 12
- 64
- 97
3
votes
1 answer
getsockopt "Invalid argument" for IPPROTO_SCTP, SCTP_STATUS
Scenario:
I've created SCTP one-to-many socket (functions that starts with big letter call corresponding standard functions with check for error and print errno to stderr)
int sock_fd,msg_flags;
char readbuf[BUFFSIZE];
struct sockaddr_in servaddr,…

4pie0
- 29,204
- 9
- 82
- 118
2
votes
2 answers
How can I call getsockopt in Java to get SO_ORIGINAL_DST
Does anyone know if there's an existing library out there that will allow me to make a call to getsockopt to get the destination IP for a socket that iptables has rerouted through my Java application?
Here's a similar question on the Netty mailing…

Jamie McCrindle
- 9,114
- 6
- 43
- 48
2
votes
0 answers
What is tcp_info->tcpi_rtt field and how it is calculated?
I am trying to write some maintenance code which may help me in identifying TCP connection quality over time. I am using getsockopt() to get tcp_info struct every second and the values I get for tcpi_rtt field in microseconds are in the…

TheChosenOne
- 95
- 5
2
votes
0 answers
Which direction (inbound or outbound) does TCP_INFO returned from getsockopt give?
The tcp_info structs provides useful stats about the current TCP connection. However, I am unsure which flow these stats refer to.
For a bidirectional connection, meaning a fd is both read from and written to, what does some of the stat refer to?…
user10150293
2
votes
2 answers
Can I find what network interface/device is handling my socket?
Say I've got a file descriptor from socket(2) and I've done a connect(2) on it -- is there any way later to determine (from inside the running program) what network device might be in use for the underlying transport? A call to stat(2) on the fd…

jhfrontz
- 1,165
- 4
- 19
- 31
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)
{
…

EmanueleRiso
- 51
- 7
2
votes
1 answer
getsockopt on OSX returns incorrect value?
I am using following program to debug a larger issue.
Now if I run same program on OSX, getopt never returns me 0 or 1, it always returns whatever value for optval I have set!!
There must be something obviously wrong in my program that is escaping…

Subodh Nijsure
- 3,305
- 5
- 26
- 45