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 options should be integer, not long #69

Merged
merged 1 commit into from
Aug 13, 2021

Conversation

wtfuzz
Copy link
Contributor

@wtfuzz wtfuzz commented Nov 30, 2018

Using anaconda3 Python 3.7 on OSX at least, the 'l' format using pack produces a 64bit result. The nanomsg C API callsnn_[set|get]sockopt() expect a pointer to an int according to the documentation.

Python 3.7.0 (default, Jun 28 2018, 07:39:16)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from struct import *
>>> pack('l', 1)
b'\x01\x00\x00\x00\x00\x00\x00\x00'
>>> pack('i', 1)
b'\x01\x00\x00\x00'
>>>

We can verify that int is in fact 4 bytes using the default clang compilter on OSX:

#include <stdio.h>
#include <stdlib.h>

int main()
{
  printf("%lu\n", sizeof(int));
  return EXIT_SUCCESS;
}
$ gcc -o test test.c
$ ./test
4

@radiocane
Copy link

Yes, pulling this would fix the bug introduced in commit:aed1521for #64

@physercoe
Copy link

Yes, after fix it the set_int_option works, otherswise it raise NanoMsgAPIError()

Copy link

@noritada noritada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also checked that this change fixes my NanoMsgAPIError(). Is it possible to apply this one?

@tonysimpson tonysimpson merged commit 24e52b7 into tonysimpson:master Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants