so when I run
import socket
import time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 8088))
s.listen(10)
while 1:
c, addr = s.accept()
print c, addr
c.send('hello')
c.close()
s.shutdown()
and
import socket
s = socket.socket()
s.connect(('127.0.0.1', 8080))
while 1:
print s.recv(2048)
I get errno 111 connection refused. What am I doing wrong
1 Answer 1
s.bind(('', 8088))
You bind on port 8088
s.connect(('127.0.0.1', 8080))
But attempt to connect to port 8080.
Note that 8088 (bind) is not the same as 8080 (connect) and that's why the connect fails, i.e. connection refused.
answered Mar 17, 2018 at 23:14
Steffen Ullrich
125k11 gold badges157 silver badges194 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py