Question

I've been dying to implement a chat server in C and Winsock for a long time now, but I haven't taken the time. Partly, because I'm still unsure of some of the conceptual ideas about building a server on Windows OS'es for something like chat.

Here are some of the issues I've been thinking about :

  • How will user x connect to my server over a generic LAN without me relying on them to type in a network address( e.g. address could be invalid, redirected to a different server, etc. )

  • If I use broadcasting to solve the above problem, will that be reliable enough for chat?

  • Will that potentially DDos a LAN since the packets will be be forcibly handled on every machine and may take a lot of bandwidth if enough people join?

  • What is the difference between multicasting and broadcasting? Is multicasting truly superior?

  • Etc.

Per request, my definition of reliability would be that I can get most of the data consistently in sent packets. In other words, I don't mind a few dropped packets, but I do mind if the data gets messed up quite a lot along the way.

Currently, I have a lot more questions than answers, but the main point I'm getting at is this :

What is the safest and most reliable way of implementing a chat over a LAN in C and Winsock?

Was it helpful?

Solution

How will user x connect to my server over a generic LAN without me relying 
on them to type in a network address( e.g. address could be
invalid, redirected to a different server, etc. )

Use a closed list of known servers, or use some broadcast based autodiscovery system.

If I use broadcasting to solve the above problem, will that be reliable 
enough for chat?

Define your requirements for reliability.

Will that potentially DDos a LAN since the packets will be be forcibly handled on every machine and may take a lot of bandwidth if enough people join?

It's a chat... the amount of generated packets will be comparatively short and small.

What is the difference between multicasting and broadcasting? Is multicasting truly superior?

Search the web. There are lots of resources and information about multicasting, most precisely, IP multicasting. In short:

  • Broadcast delivers to all hosts on a broadcast domain. Multicast delivers to all hosts that have explicity joined a multicast group, which may not be in the same broadcast domain (see last point).

  • Broadcast forces a switch to forward broadcast packets to all its interfaces. Intelligent switches can benefit from peeking at IGMP packets to know which interfaces multicast packets have to be forwarded to.

  • Broadcast cannot treepass a broadcast domain. Multicast packets can traverse a router, if it's configured to route multicast (search for M-bone)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top