Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import thread
- HOST,PORT=('my ip',8200)
- con_socket=socket.socket()
- def main():
- try:
- con_socket.connect((HOST,PORT))
- thread.start_new_thread(recv_msg,())
- while True:
- msg=raw_input()
- print "You Wrote: "+msg
- con_socket.send(msg)
- except socket.timeout:
- print "connection failed"
- con_socket.close()
- except socket.error:
- print("connection dropped")
- con_socket.close()
- con_socket.close()
- def recv_msg():
- while True:
- try:
- msg=con_socket.recv(1024)
- print msg
- except socket.error:
- con_socket.close()
- break
- con_socket.close()
- if __name__ == '__main__':
- main()
- con_socket.close()
Add Comment
Please, Sign In to add comment