我刚刚从http://www.epx.com.br/pysctp/安装了pysctp,但是我无法让基本示例正常工作。我可能做错了什么?
我正在使用Red Hat Linux。
Python 2.7.2 (default, Oct 25 2011, 10:11:43)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> import sctp
>>> sk = sctp.sctpsocket_tcp(socket.AF_INET)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python2.7/lib/python2.7/site-packages/sctp.py", line 1644, in __init__
sctpsocket.__init__(self, family, TCP_STYLE, sk)
File "/usr/local/python2.7/lib/python2.7/site-packages/sctp.py", line 1016, in __init__
self.events = event_subscribe(self)
File "/usr/local/python2.7/lib/python2.7/site-packages/sctp.py", line 623, in __init__
self.__dict__.update(self.container._get_events())
File "/usr/local/python2.7/lib/python2.7/site-packages/sctp.py", line 1356, in _get_events
return _sctp.get_events(self._sk.fileno())
IOError: [Errno 22] Invalid argument
最佳答案
有人破坏了ABI(为sctp_event_subscribe添加了更多字段,内核希望用户空间需要新的数量)。这是一个难题,正确的解决方案是使内核接受已针对具有较小struct_event_subscribe的 header 编译的旧应用程序,而只是不给它们新字段...)。甚至更新到lksctp-devel中的新样式 header 并重新编译所有内容。
--- _sctp.c~ 2011-12-20 16:48:45.000000000 +0200
+++ _sctp.c 2011-12-20 16:49:23.498912252 +0200
@@ -832,8 +832,9 @@
{
PyObject* ret = 0;
int fd;
+ char padding[4]; // Happily overflowing here...
struct sctp_event_subscribe v;
- socklen_t lv = sizeof(v);
+ socklen_t lv = 10; // Come to think of it, it could have been 9 at some point
if (PyArg_ParseTuple(args, "i", &fd)) {
if (getsockopt(fd, SOL_SCTP, SCTP_EVENTS, &v, &lv)) {
关于python - 如何开始使用Python SCTP堆栈(pysctp)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8522192/