0

I have a basic python socket, like:

server.py

import socket
ip = '192.168.2.231'
port = 2005
addr = (ip, port)
serv_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serv_socket.bind(addr)
serv_socket.listen(2)
con, cliente = serv_socket.accept()
receive = con.recv(1024)
if receive == '0123456789':
 #print "Accepted ACK"
 HERE - how can i send a message to client.py back
serv_socket.close()

How can i respond to the client.py that the sent ACK is correct? On line 16(server.py) I perform an IF and print a message, I want send a message back to the client.py saying that the ACK is invalid / invalid

asked Feb 19, 2018 at 13:16

1 Answer 1

1

You'll just use the client socket to send a response.

con, cliente = serv_socket.accept()
receive = con.recv(1024)
if receive == '0123456789':
 con.send("ACK")
serv_socket.close()
answered Feb 19, 2018 at 13:28
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.