编程代写｜CSE 4/589 Programming Assignment 1: Text Chat Application
Develop the client and server components of a text chat application, consisting of one chat server and multiple chat clients over TCP connections.
2.1 Socket Programming
Beej Socket Guide: http://beej.us/guide/bgnet
2.2 Install the PA1 template
Read the document at CSE 4/589: PA1 Template in full and install the template.
You should complete this step before reading further.
It is mandatory to use this template.
2.3 Stage and Report
There are two stages in this programming assignment, and each stage has a deadline. Stage 1 is to implement the basic login functionality for the client and server applications, and in Stage 2, you will work on some advanced features for your application based on your work in Stage 1.
The functionalities required in Stage 1 are marked in yellow.
The functionalities required in Stage 2 are marked in blue.
Write a report for each stage. Follow the instructions in the Stage 1 Report Template and Stage 2 Report
Template. Your submission will NOT be graded without submitting the reports.
We will not grade the Stage 2 sections by the Stage 1 deadline. Similarly, NO Stage 1 sections will be graded at the Stage 2 deadline. This is a hard requirement and no exception for everyone, so please keep your pace up.
3.1 Programming environment
You will write C (or C++) code that compiles under the GCC (GNU Compiler Collection) environment.
Furthermore, you should ensure that your code compiles and operates correctly on 5 dedicated hosts/machines, which will be provided to you by the instructor. Your code should successfully compile using the version of gcc (for C code) or g++ (for C++ code) found on the 5 dedicated hosts and should function correctly when executed.
NOTE: You are NOT allowed to use any external (not present by default on the dedicated hosts) libraries for the socket programming part. Bundling of code (or part of it) from external libraries with your source will not be accepted either. You can however use external modules for other parts of the assignment (like maintaining a linked list). If you are not sure whether you are allowed to use an external library or not,consult with the course staff. Further, your implementation should NOT invoke any external binaries (e.g.,ifconfig, nslookup, etc.) and should NOT involve any disk I/O unless explicitly mentioned in the PA description.
Use TCP Sockets only for your implementation.
Use the select() system call only for handling multiple socket connections. Do not use multi-threading or fork-exec.
3.3 Running your program
Your program will take 2 command line parameters:
1. The first parameter (s/C) indicates whether your program instance should run as a server or a client.
2. The second parameter (number) is the port number on Which your process will listen for incoming connections. In the rest of the document, this port is referred to as the listening port.
E.g, if your executable is named assi gnment1:
$ ./assi gnment1 s 4322
$ ./assi gnment1 C 4322
4. Output Format
We will use automated tests to grade this assignment. The grader, among other things,will also look at the output generated by your program. Towards this end, ALL the required output (as described in section 5) generated by your program needs to be writen to BOTH stdout and to a specific log file. Later sections provide the exact format strings to be used for output, which need to be strictly followed.
4.1 Print and LOG
We have already provided a convenience function for this purpose in the template (see src/logger.c and include/logger.h)， which writes both to stdout and to the logfile. You should use ONLY this function for all output described in this assignment. On the other hand, if you want to output something more to stdout (for debugging etC.) than whats described, do NOT use this function and rather use native C/C++ function calls. Any extra output in the log file will cause the test cases to fail.
To use the function, you will need to have the following statement at the top of your .c/.cpp source file(s) where you want to use this function:
#include “../include/logger . h”
The function is designed to behave almost exactly as printf. You can use the function as:
cse4589_ print_ and. _log(char* format， …
Read the comments above the function definition contained in the src/logger.c file, for more information on the arguments and return value.