Socket.sock invalid value
wrobell opened this issue · 1 comments
wrobell commented
According to nn_socket
man page, the function returns file descriptor, so Socket.sock
attribute should reflect this.
If we run
import nnpy
sub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
sub.bind('tcp://*:5555')
print(sub.sock)
The 0
will be printed.
strace
gives the following in its output for above script
$ grep -e ^socket -e ^bind log
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 7
bind(7, {sa_family=AF_INET, sin_port=htons(5555), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
So Socket.sock
should be 7
, not 0
.
wrobell commented
I have just read the nn_socket
man page more carefully
Note that file descriptors returned by nn_socket function are not standard file descriptors and will exhibit undefined behaviour when used with system functions. Moreover, it may happen that a system file descriptor and file descriptor of an SP socket will incidentally collide (be equal).
http://nanomsg.org/v1.0.0/nn_socket.3.html
This issue is invalid.