August 2002
Intermediate to advanced
576 pages
13h 54m
English
The System.Net.Sockets namespace contains classes used to create applications that work directly with the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). These classes build on the native socket classes discussed in the Programming with Native Sockets section later in this chapter.
To illustrate the use of the TCP client classes, we’ll read the index page from the Microsoft Web site. Here is a Java example using the Socket class:
import java.net.*; import java.io.*; public class SocketClient { public SocketClient() throws IOException, UnknownHostException { Socket x_socket = new Socket("www.microsoft.com", 80); PrintWriter x_writer = new PrintWriter(x_socket.getOutputStream(), true); x_writer.println("GET ...Read now
Unlock full access