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

1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any...
1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any positive integer n, it will print out the sum of the squares from 1 to n. For example given 3 the algorithm will print 14 (because 1 + 4 + 9 =14) You can use multiplication denoted as * in your solution and you do not have to define it (For example. 3*3=9) For example if n is 6 it will print: The sum...
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...
Consider the following pseudocode for insertion-sort algorithm. The algorithm sorts an arbitrary array A[0..n − 1]...
Consider the following pseudocode for insertion-sort algorithm. The algorithm sorts an arbitrary array A[0..n − 1] of n elements. void ISORT (dtype A[ ], int n) { int i, j; for i = 1 to n – 1 {     //Insert A[i] into the sorted part A[0..i – 1]     j = i;     while (j > 0 and A[j] < A[j – 1]) {         SWAP (A[j], A[j – 1]);         j = j – 1 }     }...
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])
Design an algorithm ( pseudocode or C ) to calculate the frequency of each of the...
Design an algorithm ( pseudocode or C ) to calculate the frequency of each of the vowels (lowercase and uppercase) in a text. The program will ask the user for a text, which will be entered by keyboard and will save, in a table (in%), the frequency of each of the vowels within the text, taking into account all the characters of the text. The text will end with the character '' # ''. Includes the emty sequence.
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?
Convolve the following two signals using the INPUT side algorithm. x[n]= 1, 0, 2, 0, 0,...
Convolve the following two signals using the INPUT side algorithm. x[n]= 1, 0, 2, 0, 0, 0, 2, 1, 0, 1 h[n]= 3, 2, 1 y[n]=?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT