Nov-22-2018, 03:32 PM
(This post was last modified: Nov-22-2018, 03:32 PM by tomislav91.)
I want to server allway ask for input and send to client,now it runs only once. I am using python 2.71. I tried to give some variable and infinite loop while give while x<10, but not working. Where is mistake?
Server
Server
import socket HOST = '192.168.10.20' PORT = 5000 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print 'Connected by', addr x = 0 while x<10: x+=1 data = conn.recv(1024) if not data: break massage = input('Enter number') print "you enter ", massage conn.sendall(str(massage)) conn.sendall(str(data)) ΕΎ #conn.close()Client
import socket HOST = '192.168.10.20' PORT = 5000 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) s.sendall('Hello, world') data = s.recv(1024) print 'Received', repr(data) #conn.close()Desire code is to send from server to clients data and in client i see all output. This is simple code, i will use for some electronics this code, but firstly i must get this done.