Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #this is just an example for an article at my wordpress
- #check the complete article at http://obernardovieira.byethost18.com
- #server side here http://pastebin.com/hPVc7Ds8
- # Echo client program
- from threading import Thread
- import socket
- def waitNewMessage(s):
- data = ''
- while data != 'finish':
- data = s.recv(1024)
- print 'Received', repr(data)
- HOST = 'localhost' # The remote host
- PORT = 50007 # The same port as used by the server
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((HOST, PORT))
- Thread(target=waitNewMessage, args=(s,)).start()
- msg_to_send = ''
- while msg_to_send != 'finish':
- msg_to_send = raw_input('What is your message?')
- s.sendall(msg_to_send)
- s.close()
Add Comment
Please, Sign In to add comment