If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Need asssistance - Server/Client Random Number game

Good morning everyone,

I have been tasked with a simple project as an interview. I am not requesting anyone show me how to do it, as that will just destroy my learning process, but I am looking for possibly some reference materials. Here is what the game will require:

C# in VS2010

Server will listen on a specific port

Server will allow multiple clients to connect

Client App will connect to server and interpret commands from the user to the server, vice versa

Client App will ask user for upper and lower number fro the guessing range

Client App will then ask user for their guess. If too low or too high, the client will let the user know.

If the user guesses correctly, it will tell the user they are correc,t tell them how many guesses they took, then start the game over.

What I am looking for is some reference materials on how to complete this project. I can complete it as just a simple application, but the whole client/server application programming is new to me.

With this being a small project, wouldn't a connection-less (UDP) protocol be better, for speed and for the sake of just completing the project?

I know TCP is more connection-oriented- verifying packets, but with such a small project and application, I shouldn't be too worried about packet loss, correct?

I wouldn't decide which to use based on "for the sake of just completing the project." Which you use would depend upon the requirements of your app. This is part of the learning process to determine your requirements and make design decisions on how to implement those requirements.

You have a very basic list of requirements right in your post although they are not worded as such. Let's just reword those as more proper type requirements:

REQ01 - Server SHALL listen on a specific port
REQ02 - Server SHALL allow multiple clients to connect
REQ03 - Client App SHALL connect to server and interpret commands from the user to the server, vice versa
REQ04 - Client App SHALL ask user for upper and lower number from the guessing range
REQ05 - Client App SHALL then ask user for their guess and if too low or too high, the client will let the user know.
REQ06 - If the user guesses correctly, it SHALL tell the user they are correct, tell them how many guesses they took, then start the game over.

Now look at each requirement and look at both TCP and UDP and determine if you can implement that requirement using each one. If you can't implement any one of those requirements with one of the protocols then that one should not be selected.

Users who have thanked Spookster for this post:

So with TCP - This protocol has more features that I will be using with the program. Since it shall allow multiple users to connect to the server, TCP is a better protocol, since it checks the readiness of the receiver. With UDP, it doesn't necessarily do this, and this is a major component of the client/server game in question.

Also, the entire handshake process seems a bit more what this program needs. We want to acknowledge a connection has been made, and transfer data between the connection.

I think TCP would be a lot better choice in regards to what is need to have this program work correctly.

Do you know of any areas that would discuss how to go about implementing this? I know how to get the application to work as just a console application, guess random numbers, but putting this into a client/server relationship is where I am struggling pretty bad right now. I have never dealt with this, so I am at a loss

Well now if I were tasked with this the next thing I would consider doing is coming up with a design approach. It helps to draw out diagrams of how the software is to be architected. The diagrams can help to visualize how to translate the requirements into modules or layers that you need to code. Since you plan to work with an OOP language that will be beneficial as it will be easier to conceptualize the different objects that you might need. Just glancing at your requirements I might suggest something like:

Server App:
Module 1: Message Processor - provides ability to open/close connections along with creating transmit messages and handles the sending of those, receiving and parsing incoming messages. And would provide an API to other modules to allow them to initiate these functions.

Module 2: Command Processor - Would be in charge of processing the command located in the messages and delegate to any other modules that will be handling the work associated with that command.

Module 3: Game Module - Could contain things like creating the random numbers to any logic needed for determing the results of the guesses.

Module 4: Control Module - Would be the main module in your app that kicks everything off and performs any miscellaneous functionality that doesn't warrant having its own module.

Client App would have a similar design with possibly reused modules in some cases since the client is just acting as the middle man between the user and the server relaying the messages back and forth. Just remember in a client/server relationship its the clients who initiate all transactions and the server just sits there waiting to receive and then respond to those requests.