Skip to content

Issue with socket in Cygwin #267

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

Open
robertschulze opened this issue Jul 27, 2023 · 0 comments
Open

Issue with socket in Cygwin #267

robertschulze opened this issue Jul 27, 2023 · 0 comments

Comments

@robertschulze
Copy link

Until Python 3.6.9 Xlib is working in Cygwin. However, now having upgraded to Python 3.6.13 I noticed that Xlib is now unable to connect to X11. The same error appears for Python 3.8 and 3.9. After overwriting _socket.cpython-36m-x86_64-cygwin.dll with the one from 3.6.9 Xlib is working again, so my guess is that this is due to some change in the socket module.

I debugged the issue a bit and found this to be working in Python 3.6.9

Python 3.6.9 (default, Jul 21 2019, 14:33:59)
[GCC 7.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> display = ":7"
>>> data = b'l\x00\x0b\x00\x00\x00\x12\x00\x10\x00\x00\x00MIT-MAGIC-COOKIE-1\x00\x00\xc5\xc1C\xc1Y}\xe6\x1e\x88P\xab\x98\xd0\x91<%'
>>> import select
>>> from Xlib.support import lock, connect
>>> name, protocol, host, displayno, screenno = connect.get_display(display)
>>> socket = connect.get_socket(name, protocol, host, displayno)
>>> i = socket.send(data)
>>> select.select([socket], [], [], None)
([<socket.socket fd=3, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, raddr=/tmp/.X11-unix/X7>], [], [])
>>> socket.recv(512)
b'\x01\x00\x0b\x00\x00\x00:\x07\xd0\xab\xb5\x00\x00\x00`\x00\xff\xff\x1f\x00\x00\x01\x00\x00\x18\x00\xff\xff\x01\x06\x00\x00  \x08\xff\x00\x00\x00\x00The Cygwin Ports project

while in Python 3.6.13 the same commands yield a Connection reset

Python 3.6.13 (default, Feb 16 2021, 07:46:47)
[GCC 10.2.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
...
>>> socket.recv(512)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ConnectionResetError: [Errno 104] Connection reset by peer

Any help would be much appreciated!

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