Web hosting reseller - 1124 Networking: Streams-Based Sockets and Datagrams Chapter 22
Thursday, April 12th, 20071124 Networking: Streams-Based Sockets and Datagrams Chapter 22 68 // send packet to server on port 5000 69 client.Send( data, data.Length, “localhost”, 5000 ); 70 displayTextBox.Text += “rnPacket sentrn”; 71 inputTextBox.Clear(); 72 } 73 } // end method inputTextBox_KeyDown 74 75 // wait for packets to arrive 76 public void WaitForPackets() 77 { 78 while ( true ) 79 { 80 // receive byte array from server 81 byte[] data = client.Receive( ref receivePoint ); 82 83 // output packet data to TextBox 84 displayTextBox.Text += “rnPacket received:” + 85 “rnLength: ” + data.Length + “rnContaining: ” + 86 System.Text.Encoding.ASCII.GetString( data ) + 87 “rn”; 88 } 89 90 } // end method WaitForPackets 91 92 } // end class Client Clientwindow before sending Clientwindow after sending a packet a packet to the server to the server and receiving it back Fig. 22.4 Fig. 22.FiFig. 22.4g. 22.4Client portion of connectionless client/server computing. (Part 3 of 3.) Fig. 22.4 The code in Fig. 22.3 defines the Server for this application. Line 28 in the constructor for class Servercreates an instance of the UdpClient class that receives data at port 5000. This initializes the underlying Socketfor communications. Line 29 creates an instance of class IPEndPointto hold the IP address and port number of the client(s) that transmit to Server. The first argument to the constructor of IPEndPoint is an IPAddressobject; the second argument to the constructor for IPEndPointis the port number of the endpoint. These values are both 0, because we need only instantiate an empty IPEndPoint object. The IP addresses and port numbers of clients are copied into the IPEndPointwhen datagrams are received from clients.
Note: If you are looking for high quality webhost to host and run your jsp application check Vision florida web design services