P1sec / pysctp

SCTP stack for Python
http://www.p1sec.com
165 stars 67 forks source link

sctp_send, error message too long #21

Closed vturik closed 6 years ago

vturik commented 6 years ago

Hi when i will try send one file or other data more than 400KB i got Error Message too long. How i can send more data with this library. Do you have work example with big files or big binary data sending ?

p1-bmu commented 6 years ago

It seems there is a max length by default around 200kB for sending a message. To handle this, it would be required to increase the send buffer (setsockopt() with SO_SNDBUF); this would need a new API in pysctp.

p1-bmu commented 6 years ago

The new API exposed in https://github.com/P1sec/pysctp/commit/f6bc61ef9a8f86c983ced9ef27dbfa3be8248774 enables to change the size of the send buffer:

>>> sk.send(220000*b'A')
[...]
OSError: [Errno 90] Message too long
>>> sk.get_sndbuf()
212992
>>> sk.set_sndbuf(1000000)
>>> sk.send(220000*b'A')
220000
>>> s.send(300000*b'A')
300000
>>> sk.get_sndbuf()
425984

In case you want to go over the default limit of the kernel (425984), you have to extend the value in /proc/sys/net/core/wmem_max

vturik commented 6 years ago

Thank you very much for help ))