logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

The goal of this assignment is to extend the chat server and client the most exciting feature will be support for emotes

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Chat Server and Client

Introduction

The goal of this assignment is to extend the chat server and client from Tutorial 11 with new features. The most exciting feature will be support foremotes. This assignment also asks you to demonstrate a number of the learning outcomes from earlier in the course: ability to learn about systemsutilities independently, use of file operations, use of fork, etc. That is, this assignment is the capstone of this course.The only new starter code provided for this assignment is: (1) A new socket.h with updates to the macro definitions. (2) A new chat_server.c that turnsoff SIGPIPE(the rest of the file is identical to the Tutorial 11 starter code). Aside from that, your solution to Tutorial 11 will be your starter code forAssignment 4.

Reliability and Security

The remarks mentioned in Tutorial 11 under the "A Note on Software Quality, Reliability, and Security" heading apply to this assignment as well. Insummary, both the client and server must validate all protocol messages received. If your client encounters an invalid protocol message, it shouldterminate. If your server encounters an invalid protocol message from a client, it should disconnect that client and continue serving the other clients.

Recommendation: Testing Client from Another Computer

We encourage you (but we are not marking this for completion) to implement optionalcommand-line arguments in the client to allow you to specify ahostname or IP address to connect to. If no command-line arguments are provided, your program should fall back to using the default host (localhost, or127.0.0.1) and port (specified in the Makefile). You should be able to implement this with just a few lines of code—see randclient.c to see how it is donethere (word of warning, though: randclient.c exits if no command-line arguments are provided, instead of falling back to a default hostname/port.

New Requirements for your Chat Program

This assignment adds a number of features to your Tutorial 11: the addition of an admin role, restrictions on usernames, the addition of emotes to thechat, and an updated protocol to enable these new features.

An Updated Chat Protocol

To s u p p o r t t h e n e w fe a t u re s , we w i l l n e e d t o u p d a t e o u r c h a t p ro t o c o l with a new message format. All protocol messages sent by your client must followthe format:PROTO_MSG_CODE USER_MESSAGE CRLFPROTO_MSG_CODE is a single character that serves to identify the type of message that the client is sending:Message code 0 (the ASCII character 0) indicates a "kick" command from the chat server administrator. In this case, USER_MESSAGE is the user nameof the client that should be kicked from the server.Message code 1 (the ASCII character 1) indicates that USER_MESSAGE is a text message consisting of a sequence of 0 to MAX_USR_MSGprintable ASCIIcharacters. This is followed by a CRLF sequence. If the client is sending their username upon connecting to the server, the message code is still 1but USER_MESSAGEmust be a user name consisting of 0 to MAX_NAME characters. This functionality should have been completed in the tutorials.Message code 2 (the ASCII character 2) indicates that USER_MESSAGE is an emote, consisting of a sequence of up to MAX_IMG_LENbytes that composea Base64-encoded JPEG file (explained later). As required by the protocol, these bytes are followed by a CRLF sequence.All protocol messages sent by your server be in the format:PROTO_MSG_CODE USER_NAME SPACE USER_MESSAGE CRLFAll of the fields in this format have already been described either above or in the Tutorial 11 instructions. The only change from Tutorial 11 to Assignment 4is the addition of the PROTO_MSG_CODE field. Note that there is no space between PROTO_MSG_CODE and USER_NAME.Due: 10 p.m. on Wednesday, April 1, 2020 (submit to your MarkUs git repository). Since this tutorial will be marked by automated scripts, pleaseensure that you follow the submission instructions exactly, including the required file names and directory structure.

Admin

One user connected to the server will be designated the admin, and that user has the ability to kick (disconnect) any user from the server.The admin is always the user that has been connected for the longest period of time. As a result, the first client to connect to the server is the first admin.If the first client disconnects from the server at some point, the next most "senior" user becomes the admin (i.e., the next user that has been around thelongest). This method is simpler than it sounds. (Hint: You don't need to keep track of time.)To k i c k a u s e r, t h e a d m i n u s e r c a n t y p e t h e fo l l ow i n g c o m m a n d i n t o t h e c l i e n t : .k username. In accordance with the protocol message format, theresulting protocol message that the client sends to the server will be 0usernamern. The server should ignoreany kick commands from non-admin users.(To reiterate: A non-admin issuing a kick should not be considered an invalid message; it should just be ignored.)

Duplicate Names

In the assignment 4 chat application, no two users can share the same user name, and they may not pick the all-caps username SERVERas theirusername. If a new user attempts to log in with an invalid username (e.g., SERVER, an oversized username, or one that is already taken), the server shouldrespond with the ASCII sequence 1SERVER Username invalid or already taken.rn and disconnect the client.

Base64 Encoding of Emotes

Base64 is a subset of ASCII. Your chat client will need to make use of the UNIX base64 utility to encode and decode data to and from Base64. Asexplained in man base64, this utility follows the RFC 4648 variant of Base64, which uses the characters A-Z, a-z, 0-9, -, and _. If necessary, = is used atthe end as a padding character to ensure that the total number of characters in the encoded data is always a multiple of 4.Base64 is very popular across many applications, which is why you can find many online toolsthat can encode/decode Base64. Its appeal is that it allowsyou to take any data and convert it into a form that can be printed as human-readable text, without any unprintable or control characters. E-mailattachments are sent in Base64-encoded form, for example. It is also a popular way of storing other data such as cryptographic keys(that "trick" worksfor any Github account set up with SSH public keys), since it makes it easier to copy them around or print them out for backup purposes.The disadvantage of Base64 is that any encoded data will be about 37% larger than the original unencoded data length. The reason why is fairlystraightforward: Since the Base64 encoding process restricts the value of each character to one of 64 printable characters out of the 256 possiblevalues that an 8-bit character can normally hold, a greater number of characters are required to represent the same data. If that confuses you, thinkabout it this way: Why is it that the number 255 can be printed with 3 characters in decimal representation, but its binary equivalent (11111111) requires 8characters to print, even though both the decimal and binary values represent the exact same number?For our chat protocol, the appeal of using Base64 is that the encoded image will never inadvertently contain any control characters, such as a CRLFsequence (i.e., 0x0D0A in hexadecimal, or rn when represented as control characters) that your server or client would interpret as a protocol messageterminator. In contrast, the original JPEG file may inadvertently contain a CRLF sequence or other control characters such as a 0x00 byte (which might beinterpreted as a string terminator by some string-handling functions in C).

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

576 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

796 Answers

Hire Me
expert
Husnain SaeedComputer science

594 Answers

Hire Me
expert
Atharva PatilComputer science

736 Answers

Hire Me
March
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30