23.3 |
Use a socket connection to allow a client to specify a text file's name and have the server send the contents of the file or indicate that the file does not exist.
|
23.4 |
Modify Exercise 23.3 to allow the client to modify the contents of the file and send the file back to the server for storage. The user can edit the file in a TextBox, then click an Update file on server button to send the file back to the server.
|
23.5 |
Multithreaded servers are quite popular today, especially because of the increasing use of multiprocessing servers. Modify the simple server application presented in Section 23.6 to be a multithreaded server. Then use several client applications and have each of them connect to the server simultaneously. Use a HashTable (namespace System.Collections) to store the client threads. HashTable provides several properties and methods of use in this exercise. Property Keys returns an ICollection of keys currently found in the HashTable. Each key can then be used in the HashTable's indexer to retrieve the corresponding value. Method Add places its argumentsa key and a valueinto the HashTable. Method Remove deletes its argumentthe keyfrom the HashTable.
|
23.6 |
Create a client/server application for the game of Hangman, using socket connections. The server should randomly pick a word or phrase from a file. After connecting, the client should be allowed to begin guessing. If a client guesses incorrectly five times, the game is over. Display the original phrase or word on the server. Display dashes (for letters that have not been guessed yet) and the letters that have been guessed in the word or phrase on the client.
|
23.7 |
Modify the previous exercise to be a connectionless game using datagrams.
|
23.8 |
(Checkers Game) In the text, we presented a Tic-Tac-Toe program controlled by a multithreaded server. Develop a checkers program modeled after the Tic-Tac-Toe program. The two users should alternate making moves. Your program should mediate the players' moves, determining whose turn it is and allowing only valid moves. The players themselves will determine when the game is over.
|
23.9 |
(Networked Morse Code) Perhaps the most famous of all coding schemes is the Morse code, developed by Samuel Morse in the 1830s for use with the telegraph system. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit and a few special characters (such as period, comma, colon and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Other representations of dots and dashes are used with light-oriented systems and signal-flag systems.
Separation between words is indicated by a space, or quite simply, the absence of a dot or dash. In a sound-oriented system, a space is indicated by a short period of time during which no sound is transmitted. The international version of the Morse code appears in Fig. 23.14.
Figure 23.14. English letters of the alphabet and decimal digits as expressed in international Morse code.
Character
|
Code
|
A
|
.-
|
B
|
-...
|
C
|
-.-.
|
D
|
-..
|
E
|
.
|
F
|
..-.
|
G
|
--.
|
H
|
....
|
I
|
..
|
J
|
.---
|
K
|
-.-
|
L
|
.-..
|
M
|
--
|
N
|
-.
|
O
|
---
|
P
|
.--.
|
Q
|
--.-
|
R
|
.-.
|
S
|
...
|
T
|
-
|
U
|
..-
|
V
|
...-
|
W
|
.--
|
X
|
-..-
|
Y
|
-.--
|
Z
|
--..
|
Digits
|
|
1
|
.----
|
2
|
..---
|
3
|
...--
|
4
|
....-
|
5
|
.....
|
6
|
-....
|
7
|
--...
|
8
|
---..
|
9
|
----.
|
0
|
-----
|
Write a client/server application in which two clients can send Morse code messages to each other through a multithreaded server application. The client application should allow the user to type English-language phrases in a TextBox. When the user sends the message, the client application encodes the text in Morse code and sends the coded message through the server to the other client. Use one blank between each Morse-coded letter and three blanks between each Morsecoded word. When messages are received, they should be decoded and displayed as normal characters and as Morse code. The client should have one TextBox for typing and one TextBox for displaying the other client's messages.
|
23.10 |
Write a bulletin board application that uses .NET remoting. Create a remote object that will allow the client application to list all available bulletins, retrieve the text of any bulletin and post a new bulletin. Each bulletin should be stored in a .txt file in the server's directory. Refer to Chapter 18, Files and Streams.
|
23.11 |
Write a quiz application that uses .NET remoting. Store one quiz question in a text file on the server machine. Allow the client to retrieve the question from the server and send an answer back to the server. You may wish to store records of who answered the quiz question correctly so the server operator can keep score.
|