So I am playing around with UDP communication in python and I finally got a little messaging thing to work but on the client side, there is a random 'b' here is my code
udpServer.py:
import socket
import time
import os
import getpass
userNonByt = getpass.getuser()
username = bytes(userNonByt, 'utf-8')
HOST = "localhost"
PORT = 5454
HOST = bytes(HOST, 'utf-8')
bytes(PORT)
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
def setmsg():
os.system('cls')
#asks user for there text to send
data = input("Send: ")
#converts there text to bytes so it can be sent in the UDP Packet
text = bytes(data, 'utf-8')
#sends the users text
s.sendto(username,(HOST,PORT))
s.sendto((text),(HOST,PORT))
#brings you back to the begining of this function
setmsg()
setmsg()
udpClient.py:
import socket
HOST = 'localhost'
PORT = 5454
HOST = bytes(HOST, 'utf-8')
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind((HOST,PORT))
while 1:
print (s.recv(30))
Can someone please help me?