Click here to Skip to main content
Click here to Skip to main content

X-O Game Through LAN

By , 19 Dec 2007
 
Screenshot - Code1.jpg

Screenshot - Code2.jpg

Screenshot - Presentation1[][[.jpg

Introduction

This code was used to implement the Tic-Tac-Toe game and play it through the LAN with a friend. Of course, we use the TCP protocol to send instructions.

Background

The TCP protocol is used to send reliable data through the network. In order to understand this code well, you must first have a general overview about the TCP transmission protocol.

Using the Code

In this project, we have two separate programs, one for the server that manages the entrance of the players and to hold messages from one player to another. The other program is the part for the clients (i.e. players) that listen to any messages coming from the server. It also performs some Event Handlers and the most important part is THREADING. For the clients, they are TCP clients for the server that listen at port 5000 for client requests.

Parts from the code look like this:

//TCP client
TcpClient client = new TcpClient("localhost", 5000);
                output = client.GetStream();
                writer = new BinaryWriter(output);
                sendr = (PictureBox)sender;    

//TCP listener
TcpListener tcplistner = new TcpListener(5000);
           tcplistner.Start();
            while (true)
            {
                
                welsock = tcplistner.AcceptSocket();
                networkstream = new NetworkStream(welsock);
                reader = new BinaryReader(networkstream);
                writer = new BinaryWriter(networkstream);

For any further details, please don't hesitate to contact me.

Enjoy!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Galaxy
Software Developer Biomedical Engineering Software
Egypt Egypt
Member
I Graduated from Biomedical and Systems Engineering july 2008 department faculty of engineering cairo university. and am interested in the field of Biomedical Engineering Software. as i think its very powerful & interseting field.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Layout  Per page   
QuestionHimemberjayjaycon14 Jan '12 - 0:08 
Hi sir, i'm from philippines. i'm just asking for a favor.. can i have the project codes of the X-O game. i just need a reference for my game project in our school. just email me at jayconwi@yahoo.com thank you
GeneralMy vote of 1memberRavi Sant5 Jan '12 - 9:34 
Please post source code and explanation
GeneralMy vote of 1memberfreedom_fence9 Mar '10 - 20:08 
You suck ,man ! Where's the source code ? At least you could of done something hard and not show the source ,but ... you are an idiot selfish bastard ..
GeneralNo sourcememberbloo200729 Jun '09 - 6:24 
Everithing looks nice.
But, as some people said before, where's the code ?
PM me if posting it is an issue.
GeneralMy vote of 1memberCaydence13 May '09 - 9:34 
No explanation of the source is given. It's basically, look at this thing I made, here's a mandatory small snippet, have fun. I didn't learn anything by reading this article.
QuestionHow to PlaymemberPreet8112 Nov '08 - 22:06 
Please Tell me how to Play this game on LAN?
Generalhello!memberBetty57 Jul '08 - 0:40 
Is there any source code for this project?
 
Betsy!

QuestionVery Nice application, want to look at source...BUT where is the source?memberAnandChavali19 Dec '07 - 19:10 
Very Nice application, want to look at source...BUT where is the source?
Thanks and Regards,
Anand.

Generalu is spelled Y.O.U. ur is Y.O.U.R.mvpJ4amieC19 Dec '07 - 4:11 
Don't belittle yourself by using txtspk in a serious article.
GeneralRe: u is spelled Y.O.U. ur is Y.O.U.R.memberGalaxy19 Dec '07 - 5:26 
Sorry if this annoyed u. (mmm sorry Y.O.U)
Enjoy!
GECOOOOOOOOO

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 19 Dec 2007
Article Copyright 2007 by Galaxy
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid