0

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

asked Mar 17, 2018 at 23:12

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.