Assignment 3 FAQ

Due February 26, 2016 11:59pm via sakai

Assignment 3 FAQ

Latest update: Sun Jun 26 19:29:26 EDT 2016

Back to assignment 3

Should the group name having printable characters be verified client side or server side? We made it server side but the directions are a little ambiguous.

You should verify it at the server since you cannot always count on whose client may be connecting to the server and whether it will send bad data.

We also define nonprintable to be ASCII characters less than 32 and greater that 128, is this correct?

Your definition of non-printable is fine since you’ll be using ASCII characters. Check the FAQ below for other options.

For our input for post if the client doesn’t echo it beforehand we expect them to control + D out of the input stream, is this acceptable?

Sure.

If a multiline message is being posted we return it as just one continuous line on a get call, is this ok or should we keep the original format?

No. You should keep to the original format. Just have the client send newlines at the end of each line.

We also have multiple print statements to verify for the user that a certain portion executed properly. Should we remove these or would you prefer that we leave them in so it’s easy to see the control flow for the program?

You can leave them in if they’re not totally cryptic or generate tons of output.

With our current functionality if no message is entered beforehand and the client creates a new group but exits before entering a message that group remains and has a message count of zero. Is this acceptable or should the group be removed?

That’s ok.

If one of the clients sends an incorrect group/user name, does the server print this message to itself, or does it send a message to the client that the name is invalid?

It sends the error message back to the client. Instead of a line with “ok”, the server sends back a lines stating “error: invalid group name”, “error: invalid command”, or “invalid user name"

I have a question regarding the header. I attach the header to the top of the message (first line) at the client and send the header + message combined to the server after the id returns “ok”. Is this okay? The protocol doesn’t seem to define how header information is sent.

You don’t attach the header at the client. The client sends a line containing the user ID message followed by possibly multiple lines of the message. At the server, you:

- parse the user ID from the client message
- get the IP address and port number from the accepted socket connection
- generate a time stamp
- put them all together into one header.

I just have a quick question about the post client. In the example:

echo “What do you call a bear with no teeth? – A gummy bear!” | post -h ls.cs.rutgers.edu jokes

What exactly is echo ? and why is there a | before post?

This example is Linux shell command. echo is a program that just prints its arguments. The | is the pipe command in the shell. It takes the output of one program (to the left of the pipe) and sends it as input to the program to the right of the pipe. For example:

ls | wc -l

lists all the files in your current directory and sends that output to the wc (word count) program. The -l option counts lines, so this pipeline of commands counts the number of files in your current directory.

For your second example, what is <<! ?

In the second example, the << is the shell directive to take the text that follows and use it as the standard input for the program. The character after the << indicates what the end of input character will be (a single line with that character ends input). Again, using the line counting example, the command:

wc -l <<@
   line 1
   line 2
   line 3
   @

will give you an output of 3. The examples I’m giving don’t require the user to enter data interactively. Your program will not care. It just reads from the standard input.

For the test-cases in the write-up, is it good enough to just write something like:

“To test proper syntax, I did a, b, c …”

or do you want us to show the commands on the terminal we did for each test case?

Just explaining what you did is fine. Don’t hesitate to provide details, however.

Is using ctrl + c or ctrl + v to exit out of post and thus conclude the message enough? Or do we need another distinctive way? Would we then need to tell the user how to exit post?

Terminating the program is fine. If you want to be more elegant, you can add a quit/exit command (or, like smtp, a single line with a period). Just document whatever you choose.

When a user runs post, is the user only able to enter one message, so one post = one message? Or can the user enter a series of lines, each line being a msg of its own?

Yes, one post command produces one message. The message, however, may be multiple lines long.

Can we assume tha we’ll be given a correctly formatted server name and a port number after the ‘-h’ and ‘-p’ tags?

You can assume the name is correctly formatted but if you can’t connect to the server on the supplied port, you should print a user-friendly error (rather than have Java print an exception message, for example). It’s reasonable to expect that the user may mistype a name.

When you call get, do you get the ‘accumulated’ messages? As in, does it show the past messages that was already read through get along with the new messages?

Yes. When you call get, you get all accumulated messages.

I was wondering if there are any restrictions on versions of python I would use for this project or is any version all right as long as I specify it into the readme?

I’m running 2.7.10 on my macs, 2.7.6 on my Linux systems, and the iLab machines seem to have 2.6.6. If you could be compatible with the lowest of these versions that will be great. I haven’t kept up on whether significant changes were added to the language. If you need to use a late version, please point that out in your writeup.

Could you please elaborate on the part where you require the post client to send a user name to the server. In the description, you’re saying that we should get the user’s log in name, but then it also says that it can be invalid. However, I don’t understand how it could be invalid if we are getting the user name straight from the computer. Just to clarify, we’re not letting the user set their own ID, correct?

Correct. The client is getting the user’s name and sending it. There’s no authentication taking place and you can override it by redefining the property by running

java -Duser.name=testname post 

I’m asking you to make sure that your server is robust enough to be able to handle the case where the name might be missing or invalid.

Could you also explain what you mean by “only printable text”? Could you give us an example of what a non-printable text is?

By printable text, I mean to make sure that the string does not contain control characters - just letters, numbers, and symbols. I also state that spaces should also be disallowed. In C, you can check with

isprint(c) && !isspace(c)

or simply

isgraph(c)

Java doesn’t provide this but you can check that the character is not a control character: !Character.isISOControl(c) and that will be good enough.

with regards to the command line input, you wrote “The command line accepts an optional -h followed by the server’s host name, an optional -p followed by the server’s port number, and a mandatory group name”. I was wondering if the -h and -p delimiters should be optional for the user to write, or optional for the client to accept (meaning should the client have to know how to handle those delimiters if they are input by the user).

The use of command-line options (flags) is common in Unix/Linux commands, where some options may accept parameters. I gave examples in the writeup. Your client should run with commands such as

get -h ls.cs.rutgers.edu mygroup

In this case you will use a hard-coded default port.

get mygroup

In this case you will use the hostname “localhost” and a hard-coded default port.

get -p 12345 mygroup

In this case you will use the hostname “localhost” and connect to the server on port 12345.

Ideally, you will be flexible and support the options in any order. For example:

get -p 12345 -h ls.cs.rutgers.edu mygroup

You cannot leave out the -h or -p strings. They identify that the next argument is a host or port. For a C langage discussion of command line options and parsing them using getopt(), see here.

I was planning to do this project in C, but it working with sockets seems much more difficult than in Java.

Working with C should not be a lot more difficult if you are comfortable with C. You can copy my example code to set up the sockets. After that, you can use the stdio library and convert the file descriptor to a FILE pointer with:

fp = fdopen(s, “rw”);

Then you can use fgets() to read lines of input and fprintf or fputs() to write lines of text to the socket.

Can I write a GUI instead of dealing with the command line?

No.

Is there any leniency with how debugging messages or items are displayed? Are you or the graders expecting exact input/output protocol as specified on the assignment page? For example, the formatting with GET client or “error: invalid group” messages - do these need to be exact?

You should not display any debugging messages on the client (unless you add support for a debug command-line option). As for the server, you can print a small amount of debugging information if you feel it will be useful. As far as displaying items, you should stick to the basic format: a header, followed by a blank line, followed by the message and blank lines separating a previous message from the next header. You can format the IP address and data to anything that looks reasonable.

The protocol itself should be exactly as described. You can modify your error messages a little bit if you feel a need to make them more descriptive.

Additionally, when displaying the IP of a poster - if it was local hosted, should we show 198.162.1.X (machine IP) or is 127.0.0.1 okay?

If you’re running the server locally and connecting to it via localhost, you can (and should) display 127.0.0.1. That is its address on that interface.

For the messages we are displaying for assignment 3, do we have to display the time stamp with its elements preinted exactly in the order you provided us or is it ok if they’re all there but out of order?

It’s ok if the timestamp looks somewhat different.

You had posted Java TCP examples on your website. Can we use it as reference material for the project, or should I not touch/see that code and try to code my own first for the assignment and then see and mess around with that code.

You can definitely use the code I posted.