hi guys I try to build an simple client server application with Python3, that works quiet god, but i fail to format the text back to a 'nomral' string. I always get the 'b' prefex infront of my printed text.
The Client Code:
import socket
SERVER_PORT = 50007
BUFSIZE = 1024
def main():
host = input("Serveradresse: ")
print()
print("Narchicht: ")
msg = input()
msg = bytes(msg, 'UTF-8')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, SERVER_PORT))
s.sendall(msg)
print("Sendet")
print()
x = input("Press enter to continue!")
s.close()
if __name__== '__main__':
main()
The server code:
import socket
ECHO_PORT = 50007
BUFSIZE = 1024
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', ECHO_PORT))
s.listen(1)
print("server Up")
conn, (remotehost, remoteport) = s.accept()
print('Connected with' + remotehost)
data = conn.recv(BUFSIZE)
print("Echo: " + repr(data))
while True:
if data:
data = conn.recv(BUFSIZE)
value = repr(data)
print("Echo: ", value)
s.close()
if __name__== '__main__':
main()
I'm shure, the solution will be easy but I am not abel to find it.
Thanks for Help.