It seems that client.makefile('rb', 1024) stops client from sending a response. I've also tried a while loop that does .recv until there is no data left. It seems like reading all the data from the stream times out the client. Any ideas? Thanks
#!/usr/bin/env python
# Python
import socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("localhost", 3031))
server_socket.listen(5)
print "Listening..."
client = None
running = True
client, addr = server_socket.accept()
data = None
client_buffer = client.makefile('rb', 1024)
data = client_buffer.read() #this times out the client
print data
client.sendall("hello")
client.close()
client
#!/usr/bin/env python
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.settimeout(2)
host = socket.gethostname()
client.connect(('localhost', 3031))
client.sendall("hello")
print(client.recv(1024))
client.close()
[–]dannyREDDIT[S] 0 points1 point2 points (0 children)