|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfaa.tg.net.Port
public class Port
The Port Class is utilized for specifying a TCP/UDP port number. Ports are consistent with equals and can be used as keys in hashTables. Ports can be used to create sockets of various types bound to the port that called them. These methods should have annotations that link to the particular constructor used.See the source: Port.java
| Field Summary | |
|---|---|
static java.lang.String |
CVS_VERSION_ID
The CVS Version ID |
private int |
port
The TCP/UDP port number |
static Port |
ZERO
A zero port; has special meanings for certain sockets. |
| Constructor Summary | |
|---|---|
Port(int port)
Construct a Port given an int |
|
Port(java.lang.String portString)
Construct a Port given a String. |
|
| Method Summary | |
|---|---|
Port |
add(PortOffset offset)
Creates a new port with the integer value being the sum of this port plus the offset given. |
int |
compareTo(Port o)
|
java.net.DatagramSocket |
createDatagramSocket()
Constructs a datagram socket and binds it to this port on the local host machine. |
java.net.DatagramSocket |
createDatagramSocket(java.net.InetAddress address)
Creates a datagram socket, bound to the specified local address and this port. |
inria.net.lrmp.Lrmp |
createLrmp(java.lang.String address,
int ttl,
inria.net.lrmp.LrmpProfile profile)
|
java.net.MulticastSocket |
createMulticastSocket()
Create a multicast socket and bind it to this port. |
java.net.MulticastSocket |
createMulticastSocket(java.net.InetAddress address)
Create a MulticastSocket bound to the specified socket address, using this port. |
java.net.ServerSocket |
createServerSocket()
Creates a server socket, bound to this port. |
java.net.Socket |
createSocket(Host host)
Creates a stream socket and connects it to this port at the specified host. |
java.net.Socket |
createSocket(java.net.InetAddress address)
Creates a stream socket and connects it to this port at the specified IP address. |
java.net.Socket |
createSocket(java.net.InetAddress address,
java.net.InetAddress localAddr,
Port localPort)
Creates a socket and connects it to the specified remote address on this remote port. |
boolean |
equals(java.lang.Object o)
|
PortOffset |
getOffset()
Generates an offset based on the last two decimal digits of this port. |
int |
hashCode()
|
int |
intValue()
Deprecated. |
java.net.DatagramPacket |
makeDatagramPacket(byte[] data,
java.net.InetAddress address)
Constructs a datagram packet for sending packets of length data.length to this port number on the specified
host. |
PortOffset |
offsetFrom(Port port)
Generates an offset based on the difference of this to the the argument. |
java.lang.Integer |
toInteger()
|
java.lang.String |
toString()
|
(package private) int |
value()
Accessor for the classes in this package. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CVS_VERSION_ID
public static final Port ZERO
private final int port
| Constructor Detail |
|---|
public Port(int port)
java.lang.NumberFormatException - if the argument is outside
the range of an unsigned short [0,65535]public Port(java.lang.String portString)
java.lang.NumberFormatException - if the string does not contain a
parsable integer, or if the parsed integer is outside
the range of an unsigned short [0,65535]| Method Detail |
|---|
public int intValue()
int value()
public java.lang.Integer toInteger()
public inria.net.lrmp.Lrmp createLrmp(java.lang.String address,
int ttl,
inria.net.lrmp.LrmpProfile profile)
throws inria.net.lrmp.LrmpException
inria.net.lrmp.LrmpException
public java.net.DatagramPacket makeDatagramPacket(byte[] data,
java.net.InetAddress address)
data.length to this port number on the specified
host. Data is not copied; a change in the byte array will be
reflected in the packet.
data - the packet data.InetAddress,
DatagramPacket.DatagramPacket(byte[], int, InetAddress, int)
public java.net.Socket createSocket(java.net.InetAddress address)
throws java.io.IOException
If the application has specified a socket factory, that factory's
createSocketImpl method is called to create the
actual socket implementation. Otherwise a "plain" socket is created.
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
address - the IP address.
java.io.IOException - if an I/O error occurs when creating the socket.
java.lang.SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.Socket.setSocketImplFactory(java.net.SocketImplFactory),
SocketImpl,
SocketImplFactory.createSocketImpl(),
SecurityManager.checkConnect(java.lang.String, int),
Socket.Socket(InetAddress, int)
public java.net.Socket createSocket(java.net.InetAddress address,
java.net.InetAddress localAddr,
Port localPort)
throws java.io.IOException
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
address - the remote addresslocalAddr - the local address the socket is bound tolocalPort - the local port the socket is bound to
java.io.IOException - if an I/O error occurs when creating the socket.
java.lang.SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.SecurityManager.checkConnect(java.lang.String, int)
public java.net.ServerSocket createServerSocket()
throws java.io.IOException
0 creates a socket on any free port.
The maximum queue length for incoming connection indications (a
request to connect) is set to 50. If a connection
indication arrives when the queue is full, the connection is refused.
If the application has specified a server socket factory, that
factory's createSocketImpl method is called to create
the actual socket implementation. Otherwise a "plain" socket is created.
If there is a security manager,
its checkListen method is called
with the port argument
as its argument to ensure the operation is allowed.
This could result in a SecurityException.
java.io.IOException - if an I/O error occurs when opening the socket.
java.lang.SecurityException - if a security manager exists and its checkListen
method doesn't allow the operation.SocketImpl,
SocketImplFactory.createSocketImpl(),
ServerSocket.setSocketFactory(java.net.SocketImplFactory),
SecurityManager.checkListen(int),
ServerSocket.ServerSocket(int)
public java.net.MulticastSocket createMulticastSocket()
throws java.io.IOException
If there is a security manager,
its checkListen method is first called
with this port
as its argument to ensure the operation is allowed.
This could result in a SecurityException.
When the socket is created the
DatagramSocket.setReuseAddress(boolean) method is
called to enable the SO_REUSEADDR socket option.
java.io.IOException - if an I/O exception occurs
while creating the MulticastSocket
java.lang.SecurityException - if a security manager exists and its
checkListen method doesn't allow the operation.SecurityManager.checkListen(int),
DatagramSocket.setReuseAddress(boolean),
MulticastSocket.MulticastSocket(int)
public java.net.MulticastSocket createMulticastSocket(java.net.InetAddress address)
throws java.io.IOException
Or, if the address is null, create an unbound socket.
If there is a security manager,
its checkListen method is first called
with this port as its argument to ensure the operation is allowed.
This could result in a SecurityException.
When the socket is created the
DatagramSocket.setReuseAddress(boolean) method is
called to enable the SO_REUSEADDR socket option.
address - address to bind to, or null for
an unbound socket.
java.io.IOException - if an I/O exception occurs
while creating the MulticastSocket
java.lang.SecurityException - if a security manager exists and its
checkListen method doesn't allow the operation.SecurityManager.checkListen(int),
DatagramSocket.setReuseAddress(boolean),
MulticastSocket.MulticastSocket(java.net.SocketAddress)
public java.net.DatagramSocket createDatagramSocket(java.net.InetAddress address)
throws java.net.SocketException
If there is a security manager,
its checkListen method is first called
with the port argument
as its argument to ensure the operation is allowed.
This could result in a SecurityException.
laddr - local address to bind
java.net.SocketException - if the socket could not be opened,
or the socket could not bind to the specified local port.
java.lang.SecurityException - if a security manager exists and its
checkListen method doesn't allow the operation.SecurityManager.checkListen(int),
DatagramSocket.DatagramSocket(int, InetAddress)
public java.net.DatagramSocket createDatagramSocket()
throws java.net.SocketException
If there is a security manager,
its checkListen method is first called
with the port argument
as its argument to ensure the operation is allowed.
This could result in a SecurityException.
java.net.SocketException - if the socket could not be opened,
or the socket could not bind to the specified local port.
java.lang.SecurityException - if a security manager exists and its
checkListen method doesn't allow the operation.SecurityManager.checkListen(int),
DatagramSocket.DatagramSocket(int)
public java.net.Socket createSocket(Host host)
throws java.io.IOException
If the application has specified a socket factory, that factory's
createSocketImpl method is called to create the
actual socket implementation. Otherwise a "plain" socket is created.
If there is a security manager, its
checkConnect method is called
with the host address and port
as its arguments. This could result in a SecurityException.
host - effectively, the IP address.
java.io.IOException - if an I/O error occurs when creating the socket.
java.lang.SecurityException - if a security manager exists and its
checkConnect method doesn't allow the operation.Socket.setSocketImplFactory(java.net.SocketImplFactory),
SocketImpl,
SocketImplFactory.createSocketImpl(),
SecurityManager.checkConnect(java.lang.String, int),
Socket.Socket(InetAddress, int)public java.lang.String toString()
toString in class java.lang.Objectpublic Port add(PortOffset offset)
offset - the offset to add.
public PortOffset getOffset()
public PortOffset offsetFrom(Port port)
throws java.lang.NumberFormatException
port - the base port
java.lang.NumberFormatException - if the offset is negative or
exceeds the maximum offset value.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int compareTo(Port o)
compareTo in interface java.lang.Comparable<Port>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||