1140 Networking: Streams-Based Sockets and (Web design careers) Datagrams Chapter 22

1140 Networking: Streams-Based Sockets and Datagrams Chapter 22 43 44 // property Location; the square’s location on the board 45 public int Location 46 { 47 get 48 { 49 return location; 50 } 51 } // property Location 52 53 } // end class Square Fig. 22.7 Fig. 22.7Fig. 22FiFi.7g. 22.7g. 22.7Class Square. (Part 2 of 2.) In this chapter, we discussed how to use C# s networking technologies by providing both connection-oriented (i.e., streams-based) transmission and connectionless (i.e., packet-based) transmission. We showed how to create a simple server and client via stream sockets, then showed how to create a multithreaded server. In Chapter 23, Data Structures and Collections, we discuss how to store data dynamically and discuss several of the key classes that belong to the C# System.Collectionsnamespace. SUMMARY Sockets are the fundamental way to perform network communications in the .NET Framework. The term socket refers to the Berkeley Sockets Interface, which was developed in 1978 to facilitate network programming with UNIX and was popularized by C and C++ programmers. The two most popular types of sockets are stream sockets and datagram sockets. Stream sockets provide a connection-oriented service, meaning that one process establishes a connection to another process, and data can flow between the processes in continuous streams. Datagram sockets provide a connectionless service that uses messages to transmit data. Connectionless services generally offer greater performance but less reliability than connectionoriented services. Transmission Control Protocol (TCP) is the preferred protocol for stream sockets. It is a reliable and relatively fast way to send data through a network. The User Datagram Protocol (UDP) is the preferred protocol for datagram sockets. UDP is unreliable. There is no guarantee that packets sent with UDP will arrive in the order in which they were sent or that they will arrive at all. The establishment of a simple server with TCP and stream sockets in C# requires five steps. Step 1 is to create a TcpListenerobject. This class represents a TCP stream socket that a server can use to receive connections. To receive connections, the TcpListenermust be listening for them. For the TcpListener to listen for client connections, its Startmethod must be called (Step 2). TcpListenermethod AcceptSocketblocks indefinitely until a connection is established, at which point it returns a Socket(Step 3). Step 4 is the processing phase, in which the server and the client communicate via methods Read and Writevia a NetworkStreamobject. When the client and server have finished communicating, the server closes the connection with the Closemethod on the Socket(Step 5). Most servers will then, by means of a control loop, return to the AcceptSocketcall step to wait for another client s connection.
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services

Leave a Reply