Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket errors in test suite: socket.error: [Errno 56] Socket is already connected #86

Closed
larsbutler opened this issue Jul 3, 2014 · 0 comments
Assignees

Comments

@larsbutler
Copy link
Member

More detailed output is here: http://pastebin.com/UnYMaLKe

This is happening when I run the test suite on OSX. This does not occur on Linux (Ubuntu 12.04). I've narrowed down the issue to the use of socket.connect followed by a socket.sendto: according to the docs, you shouldn't do this.

I made a small script to reproduce the problem, and have confirmed the differing behaviors on OSX and Linux.

import socket

receiver = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sender = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

addr = ('127.0.0.1', 27000)
receiver.bind(addr)
sender.connect(addr)

num_bytes = sender.send(b'foo')
print('Received: %s' % receiver.recv(num_bytes))

num_bytes = sender.sendto(b'bar', addr)
print('Received: %s' % receiver.recv(num_bytes))

On Linux, the output is:

Received: b'foo'
Received: b'bar'

On OSX, the output is:

Received: foo
Traceback (most recent call last):
  File "socktest.py", line 13, in 
    num_bytes = sender.sendto(b'bar', addr)
socket.error: [Errno 56] Socket is already connected

I've tested this script with multiple versions of Python, and the behavior is the same: the Linux socket implementation is more forgiving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant