Archived

This topic is now archived and is closed to further replies.

WebsiteWill

Network Coding Question

Recommended Posts

When coding for a network app I have seen most tutorials simply hump everything into pretty much one class and say "Here". Now in practice, wouldn''t it be a good idea to create a base class that has the functionality that client and server both share and then derive a class for the client and one for the server with any specific abilities? Not sure how this would affect speed but it seems like it would be a lot more secure as then clients would have no way to get access to any server specific code. Is this a good idea to code this way? Or is the single network class the way to go for reasons I am not aware of? Thanks, Webby

Share this post


Link to post
Share on other sites
Everything should have its reason. So you have to ask yourself whether you really need to do this or other way. Do you have any specific reasons to do that? That really depends on your app.

"I''ll be Bach!" (c) Johann Sebastian Schwarzenegger

Share this post


Link to post
Share on other sites
Well in a peer to peer type of game I''d say there is no reason for it as every computer is sending/receiving the same type of information.

But, with a server client setup especially where the server might be in charge of critical data like housing a database or some such then I''d say it would probably be beneficial to give clients as little information as possible in regards to how the server code is written. It won''t stop every attack on the server but I think it would certainly deter a few of them. Well I hope so anyway. I realize that there are more robust methods for securing a server but IMO any small detail to make it more secure should be taken. Especially when dealing with info critical servers.

I also realize that with most online games the actual database and game logic machines are located behind the login server and various firewalls. This just seemed like a little more for hardly any more work at all.

In fact it would probably make the code more managable since the server and client can be two completely distinct objects (moreso than using multiple objects of the same class).

Webby

Share this post


Link to post
Share on other sites
Well... In case of the UDP data transfer the actual code responsible for sending and receiving data is equal on both client and server, but the server has to manage "connections" (in fact UDP is connectionless, but what i mean is data transfers between different clients), so you would definitely have to create a sort of a manager on top of the server low-level socket code. And I wouldn''t share it with the clients, because they don''t need to know about how things are organized.

And as for the TCP it is completely different and the answer is: YES, you need to divide your code on two parts, and don''t try to create code which would be applicable on both client and server.

You will probably have to devote about a month for designing a stable client-server structure for a MMOG.

That''s it.

"I''ll be Bach!" (c) Johann Sebastian Schwarzenegger

Share this post


Link to post
Share on other sites
Well I think I just found a pet project for the summer. Assuming of course that once I create a stable set of networking code that would actually work with a MMOG that it won''t change very much. Got to start somewhere I guess, and I can actually see this as being a fairly managable piece to work with given that I have a 3 month summer break starting next week! Will be a great learning experience if nothing else.

Cheers,
Webby

Share this post


Link to post
Share on other sites