typeerror:byte like object is required - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: typeerror:byte like object is required (/thread-5033.html) |
typeerror:byte like object is required - rajeev1729 - Sep-15-2017 #server.py import socket # Import socket module s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Create a socket object host = socket.gethostname() # Get local machine name port = 12345 # Reserve a port for your service. s.bind((host, port)) # Bind to the port s.listen(5) # Now wait for client connection. while True: print("waiting for client connection" ) c, addr = s.accept() # Establish connection with client. print ('Got connection from', addr) c.send('Thank you for connecting')) c.close() # Close the connection#client.py import socket # Import socket module s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Create a socket object host = socket.gethostname() # Get local machine name port = 12345 # Reserve a port for your service. s.connect((host, port)) print(s.recv(1024)) s.close # Close the socket when done RE: typeerror:byte like object is required - nilamo - Sep-15-2017 Quote:s.close # Close the socket when done Your comment doesn't match your code. If you want to close the socket, you need to call the close() function. Just referencing the function doesn't call it.
|