Some Program #1 Notes

Hey guys, here are some Program #1 notes that I though you may find helpful:

  • It ended up that BILLTP gui client is just a general sort of telnet gui that sends commands to a server at a (IP, port) and echos the response of that server.
  • Speaking of my gui... here's the current state of the art (ha!). The tiny window below consists of a variety of the following gui objects: JFrame, JPanel, JLabel, JTextField, JTextArea, JScrollPane:

  • I turned my user's typed request into an array of tokens using the split() method in the String class. It's something like this:
String[] requestTokens;
// read command and parameters into request String
requestTokens = request.split("\\s")
  • You can turn a String into an int using Integer.parseInt()
  • I used PrintWriter objects to make the output stream easier to use (methods like print and println are available). The only trick is that you have to flush() the PrintWriter to get the characters to actually be sent. You can do this each time you print, or tell the PrintWriter to auto-flush when you create it.

Finally... remember:

  • The Java API has all the details for you online at java.sun.com/j2se/1.5.0/docs/api/
  • The Java tutorials have really great examples
  • Email and/or see me if you need help. Also, I hope to have some lab time Tuesday night to take your questions as well
  • Priorities: get your client/server protocol working, high quality code, documented code using Javadoc, and lastly a pretty gui

thanks... yow, bill

PS - Below is my BILLTP protocol definition for your enjoyment.


BILLTP Protocol Definition

The Better Internet Lists of Lists Trasnfer Protocol (BILLTP) provides an Internet interface to my favorite lists... things like movies and quotes and students, you know. BILLTP was created for CSC 469 Program #1.

BILLTP is simple. Here a table of the client requests (commands) and their respective server replies:

Client Request Server Action/Reply
LISTS Server lists all the lists that it currently knows about

Reply is a comma-separated string list names. If no lists are available, then an empty string "" is returned. An example reply: "movies,quotes,1969 Chicago Cubs baseball players"

LIST <num> Server sets the "current list" to the number specified. If <num> is not specified or out of range, then a list is chosen randomly.

Reply is the number of objects in the current list. If no lists are available to the server, then 0 is returned.

ITEM <num> Retrieve the <num> element in the list. If <num> is not specified or out of bounds, then an item is chosen randomly and returned.

Reply is the item specified in the list.

EXIT Closes the server's socket connection to the client.

Reply is "OK".

BILLTP uses port number 7870.

that's it... yow, bill

wtkrieger@noctrl.edu