Protocol, Chat, & LAN/Internet Play
Wednesday, September 2, 2009 7:49The following could probably easily be considered three ideas in one, but because the protocol idea seems to ‘bridge’ the other two I decided on an all-inclusive post.
I would like to write my own application-layer protocol that would allow me transfer the data, whether it be text (for chat) or something else relevant to my application(s).
The following idea is quoted from JavaWorld.com:
“…develop an application protocol that defines a more powerful level of dialog between a client and the server. Typically, such a protocol would encapsulate messages between the client and server by transmitting a header and a body with each message; the header identifies the type of the message and the length of the message body, and the body contains the actual message information…
When it comes to implementing an application-layer protocol, there are two main options. The protocol can be supported explicitly by all applications, so that when a client is sending a message, it manually inserts the appropriate header information. An alternative, however, and much more elegant solution, is to abstract the protocol behind a set of stream classes. The specifics of header construction and insertion can be handled automatically by the stream classes, and the client is then left with much the same interface as before: Clients write messages to a stream, but instead of flushing the stream, they call a method that attaches appropriate headers and sends the encapsulated message.”
I will most likely start with creating my own chat program; however, I am not sure how to work the server side of things. Ideally it would be nice to host the server side on my web hosting provider, however, not sure if that is doable. Then I could use that to communicate between the clients and not have to worry about punching holes in the users firewall. The other option, if I have to, is to have one individual act as the server and then the other party connects to them. This may work fine if just two individuals are communicating (like in a game of SOS), but probably not realistic in a more sophisticated environment.
A flexible chat program would be handy for if I make my games (or perhaps other application types) communicate over the LAN/Internet to allow users to chat while playing and also (perhaps by modifying/enhancing the code) pass other application data between the clients. Otherwise, and perhaps a better solution, I would have to have another application protocol that handles non-chat information, i.e.: game play.
If I have the resources to do this, it would probably be a great way to learn something new and enhance my programming skills as I really enjoy it and you can never know enough, if you ask me. Well at least when it comes to most things.