Closed neilschark closed 4 years ago
Actually, bindx() works correctly, with multiple addresses too. You just need to set the same port for all the interfaces to bind.
This is the output produced after the last commit (after enabling the debug output during the build stage):
$ ipython
fromPython 3.5.2 (default, Oct 8 2019, 13:06:37)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from sctp import *; from socket import *
In [2]: sk = sctpsocket_tcp(AF_INET); a1, a2 = ('127.1.1.1', 5000), ('127.2.1.1', 5000); sk.bindx([a1, a2])
[DEBUG to_sockaddr] converting caddr: 127.1.1.1, port: 5000
[DEBUG to_sockaddr] sockaddr result is family: 0x2, s_addr: 0x101017f, port: 0x8813
[DEBUG bindx] x: 0, caddr: 127.1.1.1, iport: 5000, saddrs_len: 16
[DEBUG to_sockaddr] converting caddr: 127.2.1.1, port: 5000
[DEBUG to_sockaddr] sockaddr result is family: 0x2, s_addr: 0x101027f, port: 0x8813
[DEBUG bindx] x: 1, caddr: 127.2.1.1, iport: 5000, saddrs_len: 32
In [3]: sk.close()
Giving a list with more than one address tupel to sctpsocket_tcp.bindx() results in an OSError: [Errno 22] Invalid argument.
I looked into the _sctp.c library and apparently the parsing into saddrs fails.
I created some prints in _sctp.c:
For example, giving the addresses:
results in the following command line output: