[stacklessexamples] r181 committed - Fix up socket connection requirements when calling 'recv*' methods, so...

2 views
Skip to first unread message

stackles...@googlecode.com

unread,
Feb 3, 2011, 10:50:20 PM2/3/11
to stackless-exa...@googlegroups.com
Revision: 181
Author: richar...@gmail.com
Date: Thu Feb 3 19:49:58 2011
Log: Fix up socket connection requirements when calling 'recv*' methods, so
that UDP sockets do not require one to have been made. Also remove
Windows-specific error codes, and use the correct errno ones.
http://code.google.com/p/stacklessexamples/source/detail?r=181

Modified:
/trunk/examples/networking/stacklesssocket.py

=======================================
--- /trunk/examples/networking/stacklesssocket.py Tue Feb 1 05:56:01 2011
+++ /trunk/examples/networking/stacklesssocket.py Thu Feb 3 19:49:58 2011
@@ -494,18 +494,18 @@
return ret

def recv(self, *args):
- if not self.connected:
+ if self.socket.type != SOCK_DGRAM and not self.connected:
# Sockets which have never been connected do this.
if not self.wasConnected:
- raise error(10057, 'Socket is not connected')
+ raise error(ENOTCONN, 'Socket is not connected')

return self._recv("recv", args)

def recv_into(self, *args):
- if not self.connected:
+ if self.socket.type != SOCK_DGRAM and not self.connected:
# Sockets which have never been connected do this.
if not self.wasConnected:
- raise error(10057, 'Socket is not connected')
+ raise error(ENOTCONN, 'Socket is not connected')

return self._recv("recv_into", args, sizeIdx=1)

@@ -559,7 +559,7 @@
if not self.connected:
# The socket was never connected.
if not self.wasConnected:
- raise error(10057, "Socket is not connected")
+ raise error(ENOTCONN, "Socket is not connected")
# The socket has been closed already.
raise error(EBADF, 'Bad file descriptor')

Reply all
Reply to author
Forward
0 new messages