Email me for any questions
Grading, max 32 points, return answers by email.
- Exercise 1: TCP client and server (4p)
- Exercise 2: SMTP client (4p)
- Exercise 3: UDP server and client(4p)
- Exercise 4: Game Client (8p)
- Exercise 5: Game Server (12p)
Instructions
- The goal is first to practice use of sockets with familiar protocols,
so you cannot use any functions, classes or libraries (e.g. C#: System.Net.HttpWebRequest or System.Net.Mail and Java: e.g. url class)
cannot be used.
- After that the goal is to implement a simple (game) protocol to a server and to a client
- As programmin language you can use e.g. Java, C, C++, C#, python or ask the lecturer if your preferred language is not on the list.
There are instructional videos (in Finnish) if they are of any help, there will be no English version of videos.
Videos here.
The videos have been moved to TIM.
https://tim.jyu.fi/view/kurssit/tie/itkp104/materiaalia/videosivu
The videos linked below among the excercises, do not work anymore.
Exercise 1 - TCP client and server
- Implement a simple HTTP client, which gets the default www-page from the test TCP server of Tools
and prints the page on screen (on the console window, no GUI reguired for any excercise).
- (a) Implement a TCP server that echos back what client sends and
adds the server's name in front of the echoed text separated by a ; -character. Below some examples.
(b) Also implement a client that that sends a text string to the server and receives the response
so that it can separate the server name and the echoed text based on the ; -character and prints them on screen e.g. as below.
Hints
Exercise 2 - SMTP client
- Implement simple SMTP client, that can communicate with the test SMTP server using HELO and QUIT commands
- Implement MAIL FROM, RCPT TO sekä DATA commands to the simple SMTP client.
Hints
SMTP Server state machine
SMTPServer.svg. An example state machine for client can be found from the videos page.
Exercise 3 - UDP Chat server
- Implement an UDP server that sends a message from a client to all other clients
that have already send a message to the server. Message format is Sender name;chat text
- Implement a client that can send at least a single message to the server and then receive
several messages from the server and prints on screen the sender and the text separated by : -character
e.g. Ari: Hello!
Hints
Exercise 4 - The client of game protocol
Implement
- Client JOIN state
- Client GAME state
The frame structure and messages of the protocol
- Protocol frame structure
- The frame has two fields: |message|value|
- Fields are separated by a space or ; -character
- Protocol messages: JOIN, DATA, ACK, QUIT
- JOIN - join the game - value = Player name
- DATA - data related to the game - value = the number quessed (in this game, same message used to deliver Client->Server and Server-Client DATA messages)
- ACK - each message is ACKed - value = status code informs of success etc. (after status code there might be text (separated by a space), this text which can contain spaces is part of the value -field)
- QUIT - game ends - value = 501 (you win) or 502 (you lose)
- Examples of ACK-message status codes that can be used (example server might have others too)
- 201 JOIN ok, waiting for second player
- 202 [opponent name], 2 players joined, you can start
- 203 [opponent name], 2 players joined, your opponent can start
- 300 DATA OK, Acknowledgement of correctly received data
- 4xx error messages (you should implement at least one)
- 400 undefined error
- 401 JOIN not possible (i.e. already 2 players playing)
- 402 Not your turn
- 403 errorneous ACK message
- 404 wrong frame format
- 407 the quess was not a number
- 500 QUIT OK, send in response to a QUIT message
The client state machine
Exercise 5 - The server of the game protocol
Last updated 10.3.2016
Back