留学生作业代写do not hesitate to contact me!
WeChat:lovexc60
CSCI 4210 — Operating Systems
Homework 4
Network Programming and Multi-Threaded Programming using C
Overview
? This homework is due by 11:59:59 PM on Tuesday, August 13, 2019.
? This homework is to be completed individually. Do not share your code with anyone else.
? You must use C for this homework assignment, and your code must successfully compile via gcc with absolutely no warning messages when the -Wall (i.e., warn all) compiler option is used. We will also use -Werror, which will treat all warnings as critical errors.
? Your code must successfully compile and run on Submitty, which uses Ubuntu v18.04.1 LTS. Note that the gcc compiler is version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1).
? Further, you must use the Pthread library. Remember, to compile your code, use -pthread to link the Pthread library.
Homework Specifications
In this fourth and final homework assignment, you will use C to write server code to implement a multi-threaded chat server using sockets. Clients will be able to send and receive short text messages from one another. Note that all communication between clients must be handled and sent via your server.
Clients communicate with your server via TCP or UDP via the port number specified as the first command-line argument. For TCP, clients connect to this port number (i.e., the TCP listener port). For UDP, clients send datagram(s) to this port number.
To support both TCP and UDP at the same time, you must use the select() system call in the main thread to poll for incoming TCP connection requests and UDP datagrams.
Your server must not be a single-threaded iterative server. Instead, your server must allocate a child thread for each TCP connection. Further, your server must be parallelized to the extent possible. As such, be sure you handle all potential synchronization issues.
Note that your server must support clients implemented in any language (e.g., Java, C, Python, MIPS, etc.); therefore, only handle streams of bytes as opposed to any language-specific structures.
And though you will only submit your server code for this assignment, plan to create one or more test clients. Test clients will not be provided, but feel free to share test clients with others via Submitty. Do not share server code. Also note that you can use netcat to test your server; but do not use telnet. Also remember the -u flag for UDP in netcat.