Digital Dave

Musings on projects, business and life.

Icon

network coding

This morning was pretty darn cold! I’m not excited for fall to come to town, but at least Calix should be happy.

I did a little network programming for the first time, ever. I have a programming project that looks like it will be pretty fun. The goal is to develop a client/server interaction, where the server allows a user to input a ‘guess’ on how the point spread will end up for our football games. Each week, the server administrator can add a game, like KSU vs KU, and allow users to guess. Only one guess is allowed per user name, but multiple users can be created by the same individual.

Once a guess has been put into the server, the server will keep track of the median from the input. This way, it’ll be easy to clarify a winner.

So the sample that I worked out was (u as in user):

U1 enters [+3] Median – +3
U2 enters +3 [+5] +4
U3 enters +3 +5 [+7] +5
U4 enters +3 +5 +7 [+10] +6
U5 enters +3 +5 +7 [+9] +10 +7
U6 enters [+2] +3 +5 +7 +9 +10 +6

So lets say the score ends up being KSU 15, KU 3. Point spread of +12. With a final line (median) score of+6

Now the final difference will be 12 – 6 which equals a +6.

So now we can easily calculate the winner.

Un = ‘guess’ – ‘final line’
U1 = +3 – 6 = -3
U2 = +5 – 6 = -1
U3 = +7 – 6 = 1
U4 = +10 – 6 = 4 <- Winner!
U5 = +9 – 6 = 3
U5 = +2 -6 = -4

I’m pretty sure this is how it is going to work. Nothing like receiving a massive amount of text on an assignment sheet, and sitting there for 10 minutes dissecting it.

I’ll need to implement two versions, a UDP version, which revolves around just a single connection, and a TCP connection, which allows multiple users to send data.

And, as if this wasn’t enough, I get to make a protocol sniffer to act as a middle man between the client and the server.

I’ve got the basic framework for the server and client done, thanks too msdn. But the basic idea of servers and clients are not too incredibly difficult to grasp. For the server: Init winsock, open a socket, bind to a port, accept connections, send and receive data. The client is darn near the same: Init winsock, open a socket, connect to a port, send and receive data.

One cool thing about this class is, we can develop in anything (almost) we really want too. Visual Basic, Java, C/C++, C#. I’ll be coding in C++ and using either Visual Basic or C# when we get to projects that need a GUI, maybe. I haven’t fully decided if I want to stick with C++ or not for that.

Good times.

Category: academic, Coding

Tagged:

David McGraw

Founder of iGotIt Games. Trader. Runner. Warrior. Motivator.