|
|
|
|
The Socket class implements client sockets (also called just "sockets"). A socket is an endpoint for communication between two machines. For a lot more detail on the API for the Socket class click here. Here's an example of how you can create a stream socket and connect it to the specified port number on the named host: Socket socket = new Socket("myhost.com", socketNo);The following: Socket socket = new Socket("myhost.com", socketNo, true);explicitly specifies that we should connect to a stream socket, whereas Socket socket = new Socket("myhost.com", socketNo, false);specifies that we should connect to a datagram socket. There are corresponding constructors where the first argument is of type InetAddress, and there are other constructors with more complex sets of arguments.
|
| The page was last updated February 19, 2008 |