1. Engineering
  2. Computer Science
  3. i am having error when i run these codes into...

Question: i am having error when i run these codes into...

Question details

I am having error when I run these codes into 2 consoles. Can someone fix it. please!

----------------------------------------------

UDPClient.py

from socket import *

send_message=input('Enter message to be sent to Server:')

server_address=('127.0.0.1',9876)
bytes_message=str.encode(send_message);

clientsocket=socket(AF_INET, SOCK_DGRAM)

clientsocket.sendto(bytes_message,server_address)

modified_message,address=clientsocket.recvfrom(1024)
print('Received Message From Server is:')
print(str(modified_message,encoding='utf_8'))

------------------------------------------

UDPServer.py

UDP_IP = 'localhost'
UDP_PORT = ''

serversocket = socket.socket(AF_INET, SOCK_DGRAM)



serversocket.bind ( UDP_IP,UDP_PORT )


while True:
    message, address = serversocket.recvfrom(1024)
    print('Received from client:' + message)


serversocket.sendto(message.encode(), address)
serversocket.close()

createServer()
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution