![]() |
Languages »
C# »
Applications
Intermediate
License: The Code Project Open License (CPOL)
X-O Game Through LANBy GalaxyPlay X-O through TCP connection |
C# (C# 1.0, C# 2.0, C# 3.0), Windows (Win2K, WinXP, Win2003, Vista, TabletPC, Embedded), Win32, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||

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.
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.
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!
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 19 Dec 2007 Editor: Deeksha Shenoy |
Copyright 2007 by Galaxy Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |