I Have written Python script using socket.
I wrote a basic chat, but it has a problem, I dunno how to use the Threading
library as well to make the Client side to work without blocking.
I tryed with While
but it says that:
thread.error: can't start new thread
This is the client code:
import socket
import threading
my_socket = socket.socket()
my_socket = socket.socket()
my_socket.connect(('127.0.0.1', 23))
print('Welcome to the chat room . You can send messages here.')
print('Choose a nickname.')
nickname = raw_input()
def rcv_msg():
print (my_socket.recv(1024))
def snd_msg():
txt = raw_input()
my_socket.send('[' + nickname + ']: ' + txt)
while True:
recv_thread = threading.Thread(target=rcv_msg)
recv_thread.start()
send_thread = threading.Thread(target=snd_msg)
send_thread.start()
How can I make it work?