Monday, November 4, 2019
Question to answer Assignment Example | Topics and Well Written Essays - 1000 words
Question to answer - Assignment Example Figure 1: Server listening to three clients at port number 1234 Question 2 There are basically two types of socket communication; connection-oriented and connection-less socket communication. Connection oriented socket communication requires handshaking from the participating ends to establish a successful connection. This kind of connection requires bi-directional communication since both the parties need to participate to establish the connection. On the contrary, connection less communication requires no such initial requirements to set up a dedicated connection between the participating ends. Connection-less communication does not require the verification of the presence of the destination. Such connections do not provide effective performance in the presence of less speed and greater interference in the environment. Stream sockets are used for connection oriented socket communication when reliability is essential in the transfer of data and messages. Datagram sockets are used fo r connection less communication when reliability is not crucial. Question 3 A series of steps has to be followed to enable successful communication between the client and the server. The first step involves the creation of the socket by creating an object of the class Socket. The parameters in the creation of the socket define the network protocol that will be created. The second step is binding the socket to a network interface; this is done by specifying a local address and a port number. The third step is to connect to a remote server; it should be verified that the server is in listening state to cater the requests of the clients. After a successful connection, transferring of data can take place by either send or receive functions. After the transfer of data and required operations, it is a good practice to close the socket so that the resource can be freed. Question 4 The socket is used to establish the connection from the clientââ¬â¢s side. An object of the socket class is created to communicate with the available server and send requests to it. The server socket is used at the server side to listen to all the objects that want to communicate with the server and send requests. The socket server listens to clients that are bound to the same port address as the server. Question 5 Threads are defined as a set of logic and statements that execute in isolation from each other. According to Shaw (2011), there might be multiple threads in a multithreaded environment where they will be sharing computing resources with each other. Threads enable programs to operate faster and stay more responsive to user input. Each thread is assigned a fraction of the time slice to execute and proceed in its own set of statements and commands. A scheduler has the responsibility of assigning time slices to all the threads. The high level states of threads are: ready, running, waiting and dead. Figure 2: States of threads (eTutorials.org, 2008) Question 6 There are two main me thods of threads that enable smooth execution of all operations and functions; synchronization and scheduling. Synchronization: As stated earlier, multiple threads can exist in a multithreaded environment. The threads have their own registers and stack but they might be sharing some data or resources that would require monitoring for its consistency and accuracy.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.