BD350           Assignment 3 - Visual Basic Socket Client                 Due: Tuesday, April 15

The purpose of Assignment 3 and 4 will be to create a shared hangman client.  Let’s break this up shared application into two deliverables.  For the first deliverable (Assignment 3), implement:

1.      a “chat” box between clients

2.      initiating a new game.  One person enters a word into their client and the length of the word is transmitted to the other client.  Placeholders for each letter are placed on the hangman portion of the screen.

3.      a telepointer, i.e. show on the other computer’s hangman area what one user is pointing at on their computer’s hangman area.

 

My informal description of how this should work (assuming the same client is open on two different computers) would be that I have a place where I can input the IP of the computer I want to connect with (might want to hard code this for testing).  Then, if the connection is made successfully, whatever is typed into the chat box on one computer is displayed on the other.  Show the username of the person who typed in the text.  Chat messages are kept in a buffer for archival reading. 

 

Then, when I start a new hangman game (assuming one is not currently going), I am prompted for a word and when I submit the word, letter placeholders corresponding to the length of my word are displayed on both my computer and the other one.  Of course, this works both ways (what if the other player wants to start a new game too?).  You can imagine that this will lead to “locking” type problems?  Well, don’t worry about that for now… J 

 

Finally, when I choose to “point” at something in the hangman graphic window, have that “pointer” show up in the exact same location on the other computer – this is called a telepointer.  For this assignment, you may implement this as a static pointer, i.e. when user A clicks, the pointer appears on user B’s workspace, but does not move.  However, please experiment with dynamic pointers, because that will be due for Assignment 4.  You will probably notice quite a lag between when the user starts “gesturing” and when the other client starts seeing their “mouse” when using TCP.  Can you think of a way around this?

 

In Assignment 4, I will ask you to work with a partner to load/save hangman graphics in a mysql database (or even as just files) on your Linux servers.

 

This individual assignment is to be done using the following zipped Visual Basic Client as a starting point.  This client has the user interface already created.  You will need to add “winsock” (a Windows Socket object) capability to send/receive TCP data.  Document all your code appropriately. 

 

The Winsock control enables you to connect to a remote computer and exchange data between both client and server computers.  For our purposes, we will use the same computer to both send and to receive data. I would suggest using two Winsock controls on your form.  One of the controls will be used to send the data to the other client and the other control will listen/accept a connection request (and receive data) from the other client.  Port numbers are increasingly being snatched up by applications – I see that ports 22222 and 22223 are currently not assigned.  Use port 22222 for sending data and 22223 for receiving data.  Send the data using the STREAM type (TCP).  Initially, I would suggest connecting to the local loopback IP (127.0.0.1) for testing.  Then, I expect you to connect to your client through the net. 

 

When using non-blocking sockets, it’s important to keep in mind that you must check the return value from every read and write operation, since it is possible that you may not be able to send or receive all of the specified data.

 

A couple of you have requested grading specifications.  Here are a few of my thoughts:

1.      If it doesn’t compile, grade = 0

2.      If it crashes during testing, grade = 0

3.      If a game cannot be opened and displayed, grade = grade -20

4.      If the chat doesn’t’ work correctly, grade = grade -20

5.      If a pointer cannot be displayed on the other computer, grade = grade -10

6.      If code is of poor quality, grade = grade -20

 

 

Helpful Links

http://www.sockets.com/

http://support.microsoft.com/support/kb/articles/Q163/9/99.asp

http://www.vbip.com/winsock-api/default.asp

http://www.vbip.com/

http://www.acky.net/vb/vbtcp/

http://www.vb-world.net/tips/tip477.html

http://www.mvps.org/vbnet/index.html?code/textapi/txscroll.htm

http://tangentsoft.net/wskfaq/resources/samples.html

http://www.vbip.com/winsock/winsock_http_02_01.asp

http://www.visualbasic.org/vbfaq/common.htm

http://tangentsoft.net/wskfaq/index.html

 

 

Here is a simple, sample application:  sample1.zip   After compiling, press the “Connect” button on the TCP Client Window.  Then, anything you type into the top textbox (either window), will appear in the lower textbox of the opposite window.  And, here is a step by step tutorial.