locked
Game/Chat Server and Sockets question RRS feed

  • Question

  • I wrote a Windows based Scrabble game that would allow users to play people on other computers over the Lan.  I think its kind of cool.  I even allow playing in different languages and Klingon.

    However I was not able to get this to work so that it could be used over the internet.  I used Sockets in this code.  However, this soon became an issue with routers and other things. I couldnt get get addressable ipAddresses thru firewalls, etc. So I thought about perhaps having something running, registering people who want to play, and routing the trafic thru the server instead of having the two computers talking directly.  I didnt want to do this because it just increases the traffic on the website.

    Now Im looking at rewriting it in Silverlight and runnning it in a browser.  However, I think that there is going to be a problem with getting a server going.  I have an ISP and a website but purchasing a dedicated server is not an option.  My previous ISP would not allow me to have a program running to listen on the ports.  Im fairly sure I will have this problem with my new ISP.

    Ive found samples of chat programs, game servers, etc.  But unless Im mistaken, they need to have an exe running to do the listening on the ports.

    So at this point Im looking for some direction and perhaps some sample code / links.  Or am I just wrong and seeing a problem that doesnt exist?

    Thanks

    ScCrow 

     

     

    Wednesday, November 18, 2009 8:33 PM

Answers

  • You can start a socket listener from a web application, just be aware that is shuts down when the app domain does. You would also need a host that allows you to open two ports, 943 for the policy file and whatever port you run on. Given that you would probably be better off using a polling duplex WCF service so you could push from the server. You could also start playing around with the UDP multi-cast support in Silverlight 4 to see if you can hook up a peer to peer service. Not sure how it works as yet but it might be worth looking into.
    Thursday, November 19, 2009 8:54 PM
  • If you don't understand what a "Policy Server" is, then you'll need to read up on it.  This is a Silverlight sockets headache, but solved easily enough.  (http://blogs.silverlight.net/blogs/msnow/archive/2008/06/26/full-implementation-of-a-silverlight-policy-server.aspx) and a requirement for getting anything to run like what you're trying to do.

    Most decent ISPs will not actively block any ports, or if they do it is possibly an error in configuration somewhere and you should contact them to correct it.  It is also very possible that you're being blocked by something more local like your router or a software firewall.

    Use http://www.auditmypc.com/firewall-test.asp and have it scan the ports you think should be open (port 943 with a silverlight policy server must be running as well).  If it reports that they're closed, then you can get into more detailed trace routes and find out exactly where it is closed, but at least you know the issue isn't with your Silverlight project.

    Monday, November 23, 2009 2:40 PM

All replies

  •  If you're going to code this in Silverlight, you might as well change your communication to use a webservice (WCF perhaps). If you host on a windows platform, this is usually allowed.

    HTH.

    Thursday, November 19, 2009 2:46 AM
  • You can start a socket listener from a web application, just be aware that is shuts down when the app domain does. You would also need a host that allows you to open two ports, 943 for the policy file and whatever port you run on. Given that you would probably be better off using a polling duplex WCF service so you could push from the server. You could also start playing around with the UDP multi-cast support in Silverlight 4 to see if you can hook up a peer to peer service. Not sure how it works as yet but it might be worth looking into.
    Thursday, November 19, 2009 8:54 PM
  • As Cameron says, you would probably have less headaches using WCF to just manage your chat server, providing you dont mind wasting a bit of bandwidth on the bloated data packets, but to be honest unless you have LOTS of users i doubt you would care...

    Monday, November 23, 2009 3:29 AM
  • If you don't understand what a "Policy Server" is, then you'll need to read up on it.  This is a Silverlight sockets headache, but solved easily enough.  (http://blogs.silverlight.net/blogs/msnow/archive/2008/06/26/full-implementation-of-a-silverlight-policy-server.aspx) and a requirement for getting anything to run like what you're trying to do.

    Most decent ISPs will not actively block any ports, or if they do it is possibly an error in configuration somewhere and you should contact them to correct it.  It is also very possible that you're being blocked by something more local like your router or a software firewall.

    Use http://www.auditmypc.com/firewall-test.asp and have it scan the ports you think should be open (port 943 with a silverlight policy server must be running as well).  If it reports that they're closed, then you can get into more detailed trace routes and find out exactly where it is closed, but at least you know the issue isn't with your Silverlight project.

    Monday, November 23, 2009 2:40 PM
  • I suggest you have a look at:

    http://www.codeproject.com/KB/silverlight/BuildASilverlight2WebChat.aspx

    It is a sample project that shows you how to build a Silverlight 2 Web Chat.  It uses a WCF Service for communication and SQL for a back end. 

    I used this sample for a base for my online chess project. It worked out quite well although I modified it to serialize its data into XML rather than store it in SQL.

     

    Saturday, December 12, 2009 10:57 AM
  • I recently built a socket-based communication library which is used in my Silverlight text-chat applications.  I also built a socket-based communication server which supports this text-based chat engine and it works flawlessly.  My chat protocol was based on a mashup of the Jabber protocol and POP3.  The server implements and supports a policy service as well.  This is very doable and is not difficult, once you understand what's involved.

    I'm not on the side of the "just use WCF" and "polling" technologies as they have their limitations and being a protocol junkie myself, I see the benefit of socket based communication and for these purposes I steer away from those other communication models.  On another note, I am currently building a silverlight proxy server (soon launched under www.silverlightproxy.net) and Silverlight ProxySocket socket class library to simplify development of my own game servers.  I think you're on the right track and would recommend you find a way to utilize your current network communication model, if nothing more than to add to the Silverlight socket experience in the world.

    If you'd like to collaborate on your Silverlight games, I've got a working communication server I can donate to the project.

    Cheers,

    SeattleDiver

    Friday, August 27, 2010 6:16 PM
  • Hi Bob

    I just received your e-mail.  Quite honestly, I had forgotten it was there and I and not received any e-mails on the other posts.

    My version of the scrabble game was written as a Windows app.  I could run up to 4 players over the Lan, and actually, I thought it worked pretty well.  I had added localization code for a few languages and you could set the on screen menus, messages, etc.  OF course, I used an online translator for those, so the correctness. I made no promises.

    I had also made it possible to play in other languages, so one could use a Russian char set, etc.  Again, I don't speak Russian, so a lot of guessing on the language stuff.  I had hoped that someone would be interested in their own languages and have some suggestions. 

    One other thing, that I thought would interesting.  I made a set of tiles for the Klingon language.  So the game can be played with those.  I don't know the language...so once again.. big time guessing on that.  Still, the capability is there.

    Just last week, I re-visited the code because I'm looking for a project to work on again, so this naturally pops up.  I know I can get around the issues I had by doing some sqlServer writes and doing polling.  What I had originally wanted to do was tunnel driectly to an internet address with out using any servers.  However, it sounds as though you may have something that may be better to work with.

    I'm not sure what you are interested in doing.  Is this a revenue producing site?  Let me know what you are thinking.

    Also, you can catch a game of mine at www.isildo.com. Click on the Scary Pumpkin on the left.  This site has been up for a while.  I have been considering removing and just trying to sell a windows version since no one ever visits the site.

    Oh yes.  I can send you a Windows version of both games if that would help.

    Thanks for your interest.

    Keith 

    scrabble@isildo.com

     

     

     

     

    Friday, August 27, 2010 10:54 PM
  • However I was not able to get this to work so that it could be used over the internet.  I used Sockets in this code.  However, this soon became an issue with routers and other things. I couldnt get get addressable ipAddresses thru firewalls, etc. So I thought about perhaps having something running, registering people who want to play, and routing the trafic thru the server instead of having the two computers talking directly.  I didnt want to do this because it just increases the traffic on the website.

    I had a similar problem when i first started with sockets, my application worked well on localhost, but server was unaccessable over internet,

     i fixed my issue with port forwarding you can check out it's site how to do it, www.portforward.com

    Friday, September 10, 2010 6:31 AM