Python Forum

Full Version: Host and port problems for UDP chat server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
While coding a chat server, I have encountered a problem when trying to bind the host IP and the port to the socket.

The socket doesn't want to read the host IP (which is just the standard loop-back 127.0.0.1) as a string, float or int.
Any help?
Here is the code in Python 3.5

host = ("127.0.0.1")

port = ("5000")

clients = []

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((float(host), int(port)))


(BTW this is the first time I have EVER tried to code something like this)
You are specifying UDP not TCP/IP is this what you wanted?
for TCP/IP change the SOCK_DGRAM to SOCK_STREAM
(May-07-2017, 04:31 PM)Larz60+ Wrote: [ -> ]You are specifying UDP not TCP/IP is this what you wanted?
for TCP/IP change the SOCK_DGRAM to SOCK_STREAM

It's a UDP server. The problem is in the host and port variables or the line:

s.bind((float(host), int(port)))