locked
ASP.NET: Custom protocol over HTTP RRS feed

  • Question

  • Hello!

    I want to create a game server and place it on my site. That site is hosted by provider so I cannot use any port except 80 (can I?). Thus I can only use standard HTTP connection stream and protocol and netTcpBinding is out of the game.

    My server need to send many small messages, so HTTP headers would consume much traffic. Is there a way to avoid their usage?

    One idea that I have is leaving first connection from client opened and transferring data through it(Request.Read()/ Response.Write()). Another idea - using Response.ClearHeaders(), but this method seems to clear only custom headers. Maybe httphandlers/modules would help?

    So the idea is creating custom protocol over HTTP, much like WebSockets. Unfortunately, I couldn't use them because I use only .NET 4.0 and my client app is not browser.

    Do you have better ideas? Any help would be appreciated.

    Thank you.


    Vladimir Khil


    • Edited by Ur-Quan Tuesday, November 27, 2012 5:34 PM
    Tuesday, November 27, 2012 5:33 PM

Answers

  • Use TCP class for your application.  You have to check with your provider what port number you are allowed to use.  Normally any unused port can be used.  I normally use port number greater than 10,000.  TCP will just give you a byte[].  TCP uses IP routing which allows max packets sizes of aorund 1500 bytes.  To be efficient, I would develop a messaging protocol that is around 1400 bytes.

    jdweng

    • Proposed as answer by Mike Feng Wednesday, November 28, 2012 10:57 AM
    • Marked as answer by Ur-Quan Wednesday, November 28, 2012 4:02 PM
    Tuesday, November 27, 2012 9:53 PM

All replies

  • Use TCP class for your application.  You have to check with your provider what port number you are allowed to use.  Normally any unused port can be used.  I normally use port number greater than 10,000.  TCP will just give you a byte[].  TCP uses IP routing which allows max packets sizes of aorund 1500 bytes.  To be efficient, I would develop a messaging protocol that is around 1400 bytes.

    jdweng

    • Proposed as answer by Mike Feng Wednesday, November 28, 2012 10:57 AM
    • Marked as answer by Ur-Quan Wednesday, November 28, 2012 4:02 PM
    Tuesday, November 27, 2012 9:53 PM
  • Thank you, I'll try.

    Vladimir Khil

    Wednesday, November 28, 2012 4:02 PM
  • My provider answered me that only ports 80 and 8080 are available. As there are many sites sitting on these ports and separated only by host-headers, I suppose I could not place TcpListener on either of these ports. So I'll try to find another solution.

    Vladimir Khil

    Wednesday, November 28, 2012 6:48 PM
  • What type data are you  sending and where is the source an sdestination.  You may want to look at webpage below to understand the speed of th einternet

    http://en.wikipedia.org/wiki/Streaming_media

    Once you download a webpage from the server to yoiur application java code is running.  So your format of the HttpRequest and HttpResponse can be any any amount of data.  You can send custom commands like "GET ABC". The first command HttpRequest that  is normally sent from a client to the server is GET and the server will return the entire source code.  then when the script start to run in the IE you are really in control of the HTTP packet layer.


    jdweng

    Wednesday, November 28, 2012 9:47 PM
  • I've said that my client app isn't browser; it's desktop application. I send simple messages of my own protocol.

    So your suggestion is like my first idea in first post, isn't it? To open the connection and keep it for additional data transmission?

    I have found another way of solving problem: I can place netTcpBinding on port 8080 and use callback mechanism to communicate with client. But this variant leads to the usage of additional WCF layer which will drop performance. So it will be the last thing I'll try.

    I'll primarily try your idea.


    Vladimir Khil

    Thursday, November 29, 2012 4:35 PM