knock_knock.mov
This is a simple knock-knock game played between client and server. It implements tcp-socket programming to simulate the game. All you have to do is start the server and run the client program and the game will proceed.
This game can be run in two modes, interactive (where you will be able to play with the computer) and non-interactive (where the client and server will communicate automatically)
First complile the code and then run the following code:
- Non-interactive
java KnockKnockServer -port <port_number> -i no
- Interactive
java KnockKnockServer -port <port_number> -i yes
First compile the code and then run the following code:
- Non-interactive
java KnockKnockClient -host <hostname> -port <port_number> -i no
- Interactive
java KnockKnockClient -host <hostname> -port <port_number> -i yes
Server | Your Response |
---|---|
Knock Knock!! | who is there? |
[name] | [name] who? |
[punch_line] | exit/play again |
Note: hostname
can be localhost
or the ip_address
of the client. Make sure that the port_number
is the same for the server and client.