Python Forum
Host and port problems for UDP chat server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Host and port problems for UDP chat server
#1
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)
Reply
#2
You are specifying UDP not TCP/IP is this what you wanted?
for TCP/IP change the SOCK_DGRAM to SOCK_STREAM
Reply
#3
(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)))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Method works as expected on host machine but not on server gradlon93 4 1,081 Jan-05-2023, 10:41 AM
Last Post: DeaD_EyE
  where to host my python script tomtom 1 1,262 Feb-09-2022, 06:45 AM
Last Post: ndc85430
  is there a way to mention port range or search for port dynamically with qConnection Creepy 0 1,486 Sep-09-2021, 03:15 PM
Last Post: Creepy
  Failing to connect to a host with WMI tester_V 6 4,372 Aug-10-2021, 06:25 PM
Last Post: tester_V
  How to take the tar backup files form remote server to local server sivareddy 0 1,900 Jul-14-2021, 01:32 PM
Last Post: sivareddy
Question download watsapp chat Orliv 1 1,758 Jan-26-2021, 07:01 PM
Last Post: Larz60+
  Chat bot akanowhere 16 5,882 Dec-12-2019, 02:47 PM
Last Post: akanowhere
  I am trying to send message in youtube live chat stylohunk 1 2,580 Jun-08-2019, 04:06 PM
Last Post: SheeppOSU
  Get host from ip antmar904 3 2,881 Jan-31-2018, 08:27 PM
Last Post: antmar904
Sad Twitch Chat Bot - Disconnects after 10 minutes sp4wny 0 3,889 Dec-20-2017, 08:28 AM
Last Post: sp4wny

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020