Java Reference
In-Depth Information
static InetAddress getByName ( String host )
static InetAddress getLocalHost ()
Returns an IP address for the specified/local host.
host
Host name or IP address
Accessors
byte[ ] getAddress ()
Returns the 4 bytes of the 32-bit IP address in big-endian order.
String getHostAddress ()
Returns the IP address in dotted-quad notation (e.g., “169.1.1.2”).
String getHostName ()
Returns the canonical name of the host associated with the address.
boolean isMulticastAddress ()
Returns true if the address is a multicast address (see Section 4.3.2).
Operators
boolean equals ( Object address )
Returns true if address is non-null and represents the same address as this InetAddress
instance.
address
Address to compare
2.2
TCP Sockets
Java provides two classes for TCP: Socket and ServerSocket . An instance of Socket represents
one end of a TCP connection. A TCP connection is an abstract two-way channel whose ends
are each identified by an IP address and port number. Before being used for communication,
a TCP connection must go through a setup phase, which starts with the client's TCP sending a
connection request to the server's TCP. An instance of ServerSocket listens for TCP connection
requests and creates a new Socket instance to handle each incoming connection.
2.2.1 TCP Client
The client initiates communication with a server that is passively waiting to be contacted. The
typical TCP client goes through three steps:
1. Construct an instance of Socket : The constructor establishes a TCP connection to the
specified remote host and port.
Search WWH ::




Custom Search