'client can't send any message with socket programming in python

I used thread and socket to connect my server and client together to send message in any time but now just my server able to send message and client just receive the message. why class send does not work in client code?


server code:

import socket
from threading import *


s=socket.socket()
s.bind(('localhost',1234))
s.listen()
print('listening...')
conn, addr=s.accept()


class send(Thread):
     while True:
          data=input('from serer: ')
          conn.send(data.encode())

class receive(Thread):
     while True:
          print (conn.recv(1024).decode())
     
receive=receive()
send=send()
send.start()
receive.start()

client code:

import socket
from threading import *


s=socket.socket()
s.connect(('localhost',1234))
print('connected')


class receiver(Thread):
     while True:
          print(s.recv(1024).decode())


class send(Thread):
     while True:
          data=input('from client: ')
          s.send(data.encode())


receiver=receiver()
send=send()

receiver.start()
send.start()
     
     


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source