Tuesday, October 15, 2019

Networking and communication sys (sockets) Assignment

Networking and communication sys (sockets) - Assignment Example In contrast, for example, when we send letter through post office, no connection is established between the sender and receiver of the letter .To reestablish connection in this connectionless communication system, next letter is the only option. Fig 2 Connection –oriented and Connectionless Socket Programming(Ginni T. 2010) 3. Analyzing the flow of code from top to bottom gives a better understanding. Set up few variables to store information on the IP address and port on which the socket server will be executed to generate socket. Next, bound it to the specified addresses and port. Wait for incoming requests to establish connections. Once a client connection is received, the socket accepts the request to handle information exchange. Client now sends some data as input, which is read by the server socket and executed. Both generated sockets are terminated after server sends output back to the client (as in Khanna S.1995). Summarizing, the four important steps in socket program ming between client and server involves; opening the socket; opening an input and output stream to the socket; reading from and writing to the socket according to server protocols; cleaning up . 4. Socket is implemented at the client side for sending requests to the machine port, and requires IP/hostname (address) of the server while Server Socket, executed on the server side, listens and answers client queries in reference to its port number. 5. Thread is the smallest unit of processes during execution that can be scheduled by an operating system. It is used for duplication of computer programs, when two or more tasks are executed concurrently. The thread has four high level states namely, ready, running, waiting and dead. Fig 3. A process with two threads of execution (Shaw Philip 2011) 6. Threads can be created by either implementing runnable interface when requirement is of single thread and extending the thread class for multiple threads. Depending on number of threads either o f the two process is preferred. Extending Thread Class Fig4.Thread Creation(Olira G.) is preferred while creating multiple threads. 7. When a thread instead of being scheduled by current operating system is lined up by virtual machine, its called green thread whereas working thread usually handles many concurrent tasks, allocating one thread to perform one task. 8. Thread is the smallest unit of processes during execution, which can be organized by an operating system whereas runnable is an interface used to create threads in the same process. Implementing a Runnable may have some advantages over extending thread while creating single thread. 9. Multithreading is the execution of different parts of a process  called  threads,  simultaneously at the same time without interfering with each other. In reference to multithreading, synchronization is the capability to control the access of multiple threads (or tasks) to the shared resources so that one thread do not alter a shared v ariable while another is in the process and hence, avoiding errors. In the diagram there are three threads of a single process, each with a different query and response. Fig5. Synchronization in Multithreading(LandrieuS.,2008) 10. Preemptive scheduling is the act of temporarily interrupting a  task  being carried out by the processor and resuming it later. Time slicing is the time period for which

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.