Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket.getsockopt bug #43322

Closed
gangesmaster mannequin opened this issue May 5, 2006 · 5 comments
Closed

socket.getsockopt bug #43322

gangesmaster mannequin opened this issue May 5, 2006 · 5 comments
Labels
stdlib Python modules in the Lib dir

Comments

@gangesmaster
Copy link
Mannequin

gangesmaster mannequin commented May 5, 2006

BPO 1482328

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2006-05-05.14:26:19.000>
created_at = <Date 2006-05-05.09:22:38.000>
labels = ['library']
title = 'socket.getsockopt bug'
updated_at = <Date 2006-05-05.14:26:19.000>
user = 'https://bugs.python.org/gangesmaster'

bugs.python.org fields:

activity = <Date 2006-05-05.14:26:19.000>
actor = 'gangesmaster'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2006-05-05.09:22:38.000>
creator = 'gangesmaster'
dependencies = []
files = []
hgrepos = []
issue_num = 1482328
keywords = []
message_count = 5.0
messages = ['28426', '28427', '28428', '28429', '28430']
nosy_count = 2.0
nosy_names = ['splitscreen', 'gangesmaster']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1482328'
versions = ['Python 2.4']

@gangesmaster
Copy link
Mannequin Author

gangesmaster mannequin commented May 5, 2006

i tested this on windows xp. the installed python
version is the 2.4.3 from the windows MSI.

when doing socket.getsockopt with buffer_size > 0, for
options like SO_LINGER or SO_SNDTIMEO, i get only 4 bytes.
although the man pages state these options hold 8
bytes. is this a bug in the pythonic version of
getsockopt or winsock?

-tomer

@gangesmaster gangesmaster mannequin closed this as completed May 5, 2006
@gangesmaster gangesmaster mannequin added the stdlib Python modules in the Lib dir label May 5, 2006
@gangesmaster gangesmaster mannequin closed this as completed May 5, 2006
@gangesmaster gangesmaster mannequin added the stdlib Python modules in the Lib dir label May 5, 2006
@splitscreen
Copy link
Mannequin

splitscreen mannequin commented May 5, 2006

Logged In: YES
user_id=1126061

According to http://www.sockets.com/winsock.htm#GetSockOpt

"The integer pointed to by optlen should originally contain
the size of this buffer; on return, it will be set to the
size of the value returned. For SO_LINGER, this will be the
size of a struct linger; for all other options it will be
the size of an integer."

The size of a linger struct is 4 bytes.

I would agree that the Python documentation for
socket.getsockopt is a little confusing.

"Get a socket option. See the Unix manual for level and
option. If a nonzero buffersize argument is given, the
return value is a string of that length; otherwise it is an
integer."

Perhaps just refer users to the OSes documentation on its
implementation of sockets?

Matt

@gangesmaster
Copy link
Mannequin Author

gangesmaster mannequin commented May 5, 2006

Logged In: YES
user_id=1406776

i don't think so:

according to http://www.sockets.com/winsock.htm#GetSockOpt
and
http://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html

struct linger is defined this way:

struct linger {
	int	l_onoff;
	int	l_linger;
}

which means 8 bytes, and the same goes for struct timeval:

struct timeval {
        long    tv_sec;
        long    tv_usec;
};

still, the getsockopt returns only 4. i looked at the python
source but i can't find the bug... perhaps its a bug with
how they use winsock?

-tomer

@splitscreen
Copy link
Mannequin

splitscreen mannequin commented May 5, 2006

Logged In: YES
user_id=1126061

Visual Studio .NET 2003 comes with WinSock.h and defines the
linger struct as,

struct linger {
u_short l_onoff; /* option on/off */
u_short l_linger; /* linger time */
};

However, on my NetBSD machine the linger struct is defined as,

struct linger {
int l_onoff; /* option on/off */
int l_linger; /* linger time in
seconds */
};

@gangesmaster
Copy link
Mannequin Author

gangesmaster mannequin commented May 5, 2006

Logged In: YES
user_id=1406776

lovely. i hate windows. i guess it's not a bug then -- it's
a feature. arghh.

and i now found that SNDTIMEO doesn't take a timeval, rather
an integer. just great. so i'll close the bug.

-tomer

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

0 participants