UQ Students should read the Disclaimer & Warning
Note: This page dates from 2005, and is kept for historical purposes.
COMP2301 – Assignment Five – Basic Network Programming in Visual Basic
This assignment is a pass/fail assignment. I achieved a pass.
The goal of this assignment is to gain experience using Visual Basic by implementing a simple network enabled application.
In this assignment, you should become familiar with:
- Network programming under Visual Studio 6
- IP addresses, Ports and Sockets
Specification
Develop a network enabled version of Tick Tack Toe with the following features:
- Auto Discovery for all active work stations within a set IP range
- Display Network Gaming traffic in a text window
- Display game local status on screen (Playing, Win, Lose, Draw, Abort)
- Display game network status on screen (Off Line, Ready, Busy)
- Publish game network status via a network port (Off Line, Ready, Busy)
- Randomly select the player who makes the first move
Each player must be able to:
- Invite other players to game by selecting a remote player from the auto discovery list
- Accept or reject an invitation from another player
- Perform all functions via mouse clicks
- Manually set the games network status at any time. (Off Line, Ready, Busy)
- Abort & Reset the game at any time.
- Change the Auto Discovery Range to any continuous sub range between 130.102.73.32 and 130.102.73.64
General operation
The applications will communicate over a number of fixed ports via simple text messages to transfer gaming status and commands.
Individual ports are specified for sending and receiving gaming traffic. It is assumed that a small number of games will be active at any one time and that all network requests will be services without delay.
Each game will format and display the content of all gaming traffic it has generated or received in a text window. The gaming commands, auto discovery requests and any other application specific messages will be presented at the bottom of the screen in a scrolling window. The last 100 gaming command and control messages should be buffered and accessible. At the top of the screen all status information must be displayed with buttons for all the gaming functions.
After launching the application the user will select Auto Discovery to generate a listing of all the active workstations.
The user may click on any one of the listed active gaming work stations and invite them to play. On the remote gaming work station a dialog box containing a detailed invitation will be displayed. The remote user may now accept or reject the invitation. If the remote user accepts the invitation the inviting system will randomly assign a player to go first. The first player must select Naught (green) or Cross (red) and click to indicate where to place their selection. The other system will automatically assign the remaining token. After this each player will make a selection in turn until the game is over. (out of turn plays are illegal)
Each end will maintain error checking and highlight any remote illegal moves in blue on the local system. If an illegal move is made the originator must display the move (O=green, X=red) and send the move to the remote player. The remote player must detect the invalid move, display the move in blue and send an illegal move message back. The originator of the illegal move must respond to the illegal move information and automatically change the colour of the illegal item on their local system. If the originator of an illegal move clicks that item (now blue) it will be removed from the game. Only after all illegal items are removed can the game proceed.
When a winning token is placed the remote system must detect the condition and notify the originator of the win. After this the winning line of X/O will be identified as a local event by colour change on both systems. The game is now over. The players will be shown a dialogue box congratulating the winner. At any time either player may Abort / Reset or Manually change the games network status. Connected players should react to all events logically.
Port definitions
- All port definitions and functions are symmetric for local and remote systems
- No dynamic ports are used by the application. (all fixed)
- Port 6000 : Discovery Request. Listening only. This port must be monitored by the application at all times. All traffic must be processed immediately.
- Port 6001 : Discovery Request. Transmit only. This port is used to send a local system’s Discovery Request to port 6000 of a remote system.
- Port 6010 : Discovery Status. Listening only. This port accepts status information from a remote systems.
- Port 6011 : Discovery Status. Transmit only. This port is used to send local system status information to port 6010 in response to a remote request.
- Port 6020 : Game commands. Listening only. This port accepts gaming commands from the remote system.
- Port 6021 : Game commands. Transmit only. This port sends gaming commands to the remote system.
Commands & Messages
(examples: Local system John Smith IP 130.102.73.53. Remote system Fred Nirk IP 130.102.73.33)
- Port 6000: This port accepts one command
only from a remote system. <Auto Discovery Request, For:IP>
ie Auto Discovery Request, For:130.102.73.53. - Port 6001: This port sends one command
only to a remote system. <Auto Discovery Request, For:IP>
ie Auto Discovery Request, For:130.102.73.32 - Port 6010: This port accepts status information
from a remote systems.
ie Auto Discovery Reply, Status: Off Line From:130.102.73.33 Players Name: Fred Nirk - Port 6011: This port sends local status
information to a remote systems. <Auto Discovery Reply, Status: Status From:IP Players
Name: name>
Auto Discovery Reply, Status: Ready From:130.102.73.53 Players Name: John Smith
Status = [Off Line, Ready, Busy] - Port 6020: This port accepts gaming messages and commands from a remote system
- Port 6021: This port sends gaming messages and commands to a remote system
Gaming Commands
Port 6020 & Port 6021
<Invitation, From:IP Players Name: Inviting
player’s name> Invite a remote player to play the game.
<Acceptance, From:IP Players Name: Accepting
player’s name> Accept an invitation to play the game.
<Assign First Player, From:IP First
Players Name: First players name> Inviting
system must select and assign the first player status.
<Select, Token: x From:IP Players
Name: name> Each player selects X
or O which is displayed on the remote screen. Token: [X|O]
<Place , Token: x Colour: x Position: xx From:IP Players
Name: name > Player places a token
on the grid A1 to C3 with Colour [R|G|B]
<Delete, Token: x Colour: x Position: xx From:IP Players
Name: name > Reports the removal of
an illegal token from a system.
<Illegal, Token: x Colour: x Position: xx From:IP
Players Name: name > Identifies an
illegal token to the remote system.
<Winner, From:IP Winners Name: winner’s
name> Notifies the remote system of game completion.
Example
Text from Network Gaming traffic window on the local system
- This traffic should be presented as a sequence of text strings one per
line in time order.
..................User selects Auto Discovery function from GUI .....................
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.32
Local Port 6010 <<< Remote Port 6011 Auto Discovery Reply, Status: Ready From: 130.102.73.32 Players Name: David Jones
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.33
Local Port 6010 <<< Remote Port 6011 Auto Discovery Reply, Status: Ready From: 130.102.73.33 Players Name: Fred Nirk
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.34
Local Port 6010 <<< Remote Port 6011 Auto Discovery Reply, Status: Busy From: 130.102.73.34 Players Name: Max Mouse
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.35 (No response from system.........)
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.36 (No response from system........)
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.37 (No response from system........)
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.38 (No response from system........)
Local Port 6010 <<< Remote Port 6011 Auto Discovery Reply, Status: Off Line From: 130.102.73.38 Players Name: Donald Duck
..................Auto Discovery continues..........
Local Port 6001 >>> Remote Port 6000 Auto Discovery Request, For: 130.102.73.64
Local Port 6010 <<< Remote Port 6011 Auto Discovery Reply, Status: Ready From: 130.102.73.64 Players Name: Another Player
. .................User selects Second Player from list Fred Nirk..........................
Local Port 6021 >>> Remote Port 6020 Invitation, From: 130.102.73.53 Players Name: John Smith
Local Port 6020 <<< Remote Port 6021 Acceptance, From: 130.102.73.33 Players Name: Fred Nirk
Local Port 6021 >>> Remote Port 6020 Assign First Player, From: 130.102.73.53 First Players Name: John Smith (Randomly select the first player)
Local Port 6021 >>> Remote Port 6020 Select, Token: O From: 130.102.73.53 Players Name: John Smith (Second player’s system displays remaining token X )
Local Port 6021 >>> Remote Port 6020 Place , Token: O Colour: G Position: B2 From: 130.102.73.53 Players Name: John Smith
Local Port 6020 <<< Remote Port 6021 Place , Token: X Colour: R Position: B1 From: 130.102.73.33 Players Name: Fred Nirk
Local Port 6021 >>> Remote Port 6020 Place , Token: O Colour: G Position: A3 From: 130.102.73.53 Players Name: John Smith
.................Play continues until John’s system detects Fred placing a token at C2 out of turn.........................
Local Port 6021 >>> Remote Port 6020 Illegal, Token: X Colour: B Position: C2 From: 130.102.73.53 Players Name: John Smith (Fred’s system must redisplay C2)
Local Port 6020 <<< Remote Port 6021 Delete, Token: X Colour: B Position: C2 From: 130.102.73.33 Players Name: Fred Nirk ( Fred removed the illegal token)
.................Play continues until Fred’s system detects the last token placed by John was the winning move.........................
Local Port 6020 <<< Remote Port 6021 Winner, From: 130.102.73.33 Winners Name: John Smith
General
- Auto Discovery IP range must be displayed on screen and show both upper and lower values. Maximum range must be hard coded.
- Players may place X or O at any time and in any order. All plays must be displayed on the local system in Red and Green.
- Reasonable error detection and handling is required.
- The application must be well behaved and terminate gracefully.
- Care must be taken during the development and testing of this application to avoid excessive network traffic.
No IP traffic should be generated outside of the specified IP / Port range.
Note: This application was coded as fast as possible, and as such does not conform exactly to the specification, and may not be stable or fit for use. The IP range is hard-coded, so without modification this application will only work in environments with a similar IP range.
Compiled (WIN32) binary (64 KB)
frmTicTacToe.frm
Code © Copyright 2004 Ned Martin
04-Jun-2004