Question

In: Computer Science

1) Using algorithm or pseudocode, describe the implementation of the server side of a public chatroom...

1) Using algorithm or pseudocode, describe the implementation of the server side of a public chatroom application with the following specification:

Any client that wishes to join the chatroom, must send the message “Hello” to the server’s IP address at port 2020. After sending the “Hello” message, the client is admitted into the chatroom. While in the chatroom, any message sent by any client must be received by all other clients. Finally, when a client decides to leave the chatroom, it sends the “Bye” message to the server. After the server sees a “Bye” message from a client, it must stop sending any further message to that client.

What kind of socket should the server application use? Why?

Solutions

Expert Solution

Implementation of the server side of a public chatroom application

1) Define the server.

2) Define type of socket to read the address and data.

3) Read the IP Address and Port entered by client ( Make sure client is aware about the parameters).

4) Bind the server to mentioned IP Address and Port.

5) Check if the Address domain of the socket in the form of IP address is right.

6) Check if the type of socket is right.

7) Then bind the server to the IP address and Port and set the number of connections, in this case 'ALL'.

8) Print and inform all the connection on the server.

9) Broadcast a message as "Hello"  to all the connection which are active but don't send to the users.

10) Connect to connection whose user object is 'Hello'.

11) If there is no Connection with " Hello" , then remove.
12) Else Accept the connection request - start thread.

13) Maintain the list of the connection.

14) Close the connection if message is "Bye" or lost connection abruptly.

15) Disconnect from the list of Socket.
16)Disconnect from the list of users.

Socket should be used in the server side are :

Address Domain Socket - Since the connection is set between multiple host on internet so, they need to have a common address.
Streaming Socket - To read theflow of data in the chatroom continuously.


Related Solutions

Problem 1: (10 marks) ALGORITHM COMPLEXITY:Write an algorithm (pseudocode but not a program) that takes a...
Problem 1: ALGORITHM COMPLEXITY:Write an algorithm (pseudocode but not a program) that takes a positive numberias an input, where i=a1a2...an,n>=3(numberwith 3 or more digits, every digit can have the value between 0 and 9–both inclusive). The algorithm should find the largest number jsuch that j=b1..bm, 1<=m<=n(numberwith m digits),andevery bk<=bk+1where1<=k<m and bk,bk+1ε{a1, a2, an}.Also, perform the computational complexity (time complexity)analysis of your algorithm and write the algorithm complexity in Big-Oh notation. Examples:Input: 23720, Output: 237Input: 9871, Output: 9Input: 1789, Output:1789Input: 2372891,...
Write an algorithm in pseudocode for the binary search method using a while loop (iterative version)...
Write an algorithm in pseudocode for the binary search method using a while loop (iterative version) The recursive ternarySearch method returns true or false depending if the element was found or not. The ternarySearch method works in a similar manner to a binary search except it uses two mid values that “divide” the array into three portions. So, it needs to consider three recursive scenarios: See sample run: Accounts are: [0] 5658845 [1] 8080152 [2] 1005231 [3] 4520125 [4] 4562555...
Write an algorithm in pseudocode for the binary search method using a while loop (iterative version)...
Write an algorithm in pseudocode for the binary search method using a while loop (iterative version) The recursive ternarySearch method returns true or false depending if the element was found or not. The ternarySearch method works in a similar manner to a binary search except it uses two mid values that “divide” the array into three portions. So, it needs to consider three recursive scenarios: See sample run: Accounts are: [0] 5658845 [1] 8080152 [2] 1005231 [3] 4520125 [4] 4562555...
Use pseudocode to describe an algorithm for the procedure: int[][] find_pairs( int array[], int value ).
Use pseudocode to describe an algorithm for the procedure: int[][] find_pairs( int array[], int value ). Given a sorted array of distinct integers and a single integer value, find all pairs of indexes in the list whose product is equal to the value. Return the index pairs on the same row of a two-dimensional array. Note, m will be the number of rows and total number of pairs found, while 2 will be the number of columns along every row...
Implement the following pseudocode in Python Consider the following pseudocode for a sorting algorithm: STOOGESORT(A[0 ......
Implement the following pseudocode in Python Consider the following pseudocode for a sorting algorithm: STOOGESORT(A[0 ... n - 1]) if (n = 2) and A[0] > A[1] swap A[0] and A[1] else if n > 2 m = ceiling(2n/3) STOOGESORT(A[0 ... m - 1]) STOOGESORT(A[n - m ... n - 1]) STOOGESORT(A[0 ... m - 1])
Pseudocode and algorithm of finding median of unordered array in linear time.
Pseudocode and algorithm of finding median of unordered array in linear time.
Show your results using all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an...
Show your results using all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application that allows a user to enter the number of text messages he or she sent last month and then displays the bill. Messages cost 25 cents each, and 8 percent tax is charged on the total.
How does the addition of computation on the server side and client side alter Sir Tim...
How does the addition of computation on the server side and client side alter Sir Tim Berners Lee’s original computational model?
Exercise 1. Write an algorithm (pseudocode) to read a set of sales data items from standard...
Exercise 1. Write an algorithm (pseudocode) to read a set of sales data items from standard input and calculate and output their total and their average. Prompt user to enter number of data items. Exercise 2. Create a test data set to verify your algorithm. How many cases are needed? Explain. Write your test data set below for submission to the EOL dropbox upon completion of your lab. Number of items List data items Expected output Case 1: Exercise 3....
Using the textbook implementation of integer node given below; public class IntegerNode { public int item;...
Using the textbook implementation of integer node given below; public class IntegerNode { public int item; public IntegerNode next; public IntegerNode(int newItem) { item = newItem; next = null; } // end constructor public IntegerNode(int newItem, IntegerNode nextNode) { item = newItem; next = nextNode; } // end constructor } // end class IntegerNode You need to implement add( ), delete( ), traverse( ) methods for an ordered linked list. And after insertion and deletion, your linked list will remain...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT