On this page:
Netcat vs netcap
8.3.0.10

E — TCP

Due Tuesday, 28 September 2021, 11:59pm

Purpose to explore the TCP libraries of the chosen programming language; to deliver software as specified; reflect on the language of your choice.

Delivery You must deliver xtcp and Tests/ in a directory called E in your repository.

All auxiliary files must be put into a sub-directory called Other.

Self-Evals Starting with this homework assignment, we will push a self-evaluation form into your homework repo (E) within a couple of hours after the deadline. The form comes with instructions and a small number of questions about your code base. You must edit the file—adding responses to the questions—and push it back to origin within 24 hours of the assignment deadline.

Not submitting a self-evaluation by this deadline will lower your score.

Partnership Evals For this milestone, we also request an evaluation of your partnership. Each individual should send an email to the head TA (Cameron), using the following format:

    Subject: Sw Dev partnership evaluation

    

    My name: Foo Bar

    My partner's name: Fumble Mumble

    Our TAHPL: Python 4.312

    

    Our partnership is ...

The body of the message can be a single sentence (e.g., "... the happiest ever") or several paragraphs with details (e.g., "Our first minute of coding .. Our second minute ..."). What you want to say is completely up you.

The head TA and the instructors will read your responses, and nobody else will.

After E we expect to dissolve some partnerships, some with lots of friction, some with very little friction or even none. If yours is one of them, you will get a partner in the same language family.

The partnership evaluation is worth 10 points.

Task Develop xtcp, a program that allows a single TCP client to connect. It then consumes a series of JSON values from the input side of this TCP connection and delivers JSON to the output side of a TCP connection. Once the connection is closed, the server shuts down.

The program takes at most one command-line argument, an integer between 2048 and 65666 65535 (inclusive). This argument specifies the port to which xtcp accepts connections. If there is no command-line argument, the program uses the default port 45678. Finally, the program waits for at most 3 seconds for a client to connect; if no client connects, the program signals an error with an informative error message.

The program’s functionality is the same as that of xjson from C — JSON. You are welcome to reuse your solution. The ideal reuse is a call to the original solution; copying the code is acceptable for an exploratory programming task.

Tests Create three tests for xtcp in the directory Tests/. You may re-use the validated tests from your solution for C — JSON or create new ones. All tests must be well-formed and valid JSON according to C — JSON.

Constraint No test file may exceed the size limit of 20Kb.

Optional Summary Memo Write two memos: experience.md and assessment.pdf.

The first reports your experiences with your exploratory programming tasks. Here are some sample questions you may ponder, especially with respect to the (rather short and compact) solution that the instructors showed you in class. How much time did it take to accomplish various tasks? What problems did you encounter with the libraries for your chosen language? How easy was it to write unit tests? How well did the unit-testing tools work? Did the chosen IDE support the programming well?

The second one states your assessment of the language based on this experience. You should honestly ask whether you still think the language is a good choice for a project that involves the explored aspects (and more).

Half a page per topic suffices. Less is more.

If this self-assessment leads you to the conclusion that you wish to switch to a different language, send these memos to your instructor and immediately make a 1-1 appointment.

Hint The netcat program (abbreviated nc) is the best way to manually send JSON information from your shell to your server:

    [login-students] $ cat 1-in.json | nc login-students.ccs.neu.edu 45678

This command connects the cat command with the nc command via a pipe. Specifically it sends the content of the 1-in.json file to nc, which in turn transmits it via TCP to the computer with the IP address login-students.ccs.neu.edu at port 45678 (if all of you use 45678 on the same computer, bad things will happen).

The following screen shot shows how you can launch xtcp on one machine (here antarctica):

On a separate machine, you can then run nc to connect to the first machine:

Here the second nc command sends JSON from login-students to antarctica, also on the ccs.neu.edu network. Note how the two command lines specify the same port. Switching between these two terminal windows takes time, and the first nc command shows what happens when you’re too slow or you haven’t launched xtcp yet.

Netcat vs netcap

There exists a whole family of netcat programs.

The one on the Linux servers is nmap netcat and it satisifies all of our needs.

Macs may vary; mine had the nmap netcat preinstalled via some developer toolkit.

On Windows it is likely not pre-installed. Windows users may wish to visit the nmap site, download the ncat executable, and add it to their path.