views:

251

answers:

4

I want to to create a simple client/server chat application.

The idea is that when one client sends a message to the server the server informs the other clients with the change.

What is the best way to do so without having to deal with firewall problems?

Can it be done with web services over http?

A: 

You can run an HTTP server on your server, and leave a connection open to it on each client.

SLaks
+1  A: 

WCF service with wsHttpBinding or basicHttpBinding plays nice with firewalls. The major problem you will face is the server informing clients for which modifying some firewall settings might be necessary.

Darin Dimitrov
A: 

You could accomplish this using a COMET style web service:

COMET (programming)

If you're building your services using WCF, you would implement a service that runs on port 80 with a Duplex Binding.

Duplex Services (MSDN)

Justin Niessner
A: 

The server needs to be listening on a port. That port needs to have access through a firewall. These two things are unavoidable. Usually you will let your server listen on port number you make up (greater than 1024 to avoid clashing). You will then let your firewall pass that port to your server.

If you're expecting ordinary folk to host a server then things will be a bit tricky. Either you need them to enable port forwarding on their home router or you need to have a centralized server for matchmaking.

This is how Skype or Halo works (Skype calls the central server a supernode). Here is an example.

C is the central Skype server. A is Alice and B is bob. Alice wants to call Bob.

C listens on some port and C's firewall lets that through
A logs into Skype, connecting to C
B logs into Skype, connecticg to C
A sends a message to C saying they want to call B
C sends a message to B (since B is already connected this is ok) saying as such.

Once the call is connected A and B send all their messages to C and C forwards them on to their destination.

Pace