0% found this document useful (0 votes)
14 views4 pages

Python Socket WinError 10057 Fix

Uploaded by

Juan Diego CR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Python Socket WinError 10057 Fix

Uploaded by

Juan Diego CR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

I'm having a problem with my Python socket program [WinError 10057] - Stack Overflow [Link]

I'm having a problem with my Python socket program [WinError 10057]


Asked 5 years, 5 months ago Modified 5 years, 4 months ago Viewed 169 times

1 de 4 10/07/2024, 8:01
I'm having a problem with my Python socket program [WinError 10057] - Stack Overflow [Link]

I was programming a simple client-server socket program that worked on two different computers. The server is a desktop with a static ip
address, and the client is a laptop connected to a Wi-Fi. Both are using Windows 10 as operating system. I also opened the firewall port.
1
Here is my code. This code works well within one computer, but WinError 10057 occurs when another computer(my laptop) tries to connect
to the server.

[Link]

from socket import *


import sys

HOST = '[Link]'
PORT = 16161
BUFSIZE = 1024
ADDR = (HOST, PORT)
CLIENT_NUM = 5

serverSocket = socket(AF_INET, SOCK_STREAM)

[Link](ADDR)
print('bind')

[Link](CLIENT_NUM)
print('listen')

while True:
try:
connectionSocket, addr_info = [Link]()
print('accept')
print('--client information--')
print(connectionSocket)

data = [Link](BUFSIZE)
print('Received data:', [Link]())
[Link]('OK'.encode())
[Link]()

except KeyboardInterrupt:
[Link](0)

[Link]

2 de 4 10/07/2024, 8:01
[Link]

from socket import *


import sys

HOST = '*.*.*.*' # server's ip address


PORT = 16161
BUFSIZE = 1024
ADDR = (HOST, PORT)

clientSocket = socket(AF_INET, SOCK_STREAM)

try:
clientSocket.connect_ex(ADDR)
[Link]('Hello!'.encode()) # WinError 10057 occurs
except Exception as e:
print(e)
print('%s:%s' % ADDR)
[Link](1)

print('connect is success')

receive = [Link](BUFSIZE)
print([Link]())

[Link]()

python sockets networking ip

Share Improve this question Follow edited Feb 12, 2019 at 2:34 asked Feb 12, 2019 at 2:23
JJeongs
31 5

Are you positive that "server's ip address" is your desktop's local ip and not its public ip? – Lord Elrond Feb 12, 2019 at 3:20
I'm having a problem with my Python socket program [WinError 10057] - Stack Overflow [Link]

The connect_ex() method returns a success/error code. What is the return that you are getting? – John Anderson Feb 12, 2019 at 4:25
1 Answer Sorted by: Highest score (default)
connect_ex() returns 10060. – JJeongs Feb 12, 2019 at 4:52

I've fixed it. I asked my organization to open the firewall ports, and the connection was successful when the firewall ports were opened.

1 Share Improve this answer Follow answered Feb 14, 2019 at 4:59
JJeongs
31 5

4 de 4 10/07/2024, 8:01

You might also like