Package oshi.software.os
Class InternetProtocolStats.IPConnection
java.lang.Object
oshi.software.os.InternetProtocolStats.IPConnection
- Enclosing interface:
- InternetProtocolStats
@Immutable public static final class InternetProtocolStats.IPConnection extends java.lang.Object
Encapsulates information associated with an IP connection.
-
Constructor Summary
Constructors Constructor Description IPConnection(java.lang.String type, byte[] localAddress, int localPort, byte[] foreignAddress, int foreignPort, InternetProtocolStats.TcpState state, int transmitQueue, int receiveQueue, int owningProcessId) -
Method Summary
Modifier and Type Method Description byte[]getForeignAddress()Gets the foreign/remote address.intgetForeignPort()Gets the foreign/remote port.byte[]getLocalAddress()Gets the local address.intgetLocalPort()Gets the local port.intgetowningProcessId()Gets the id of the process which holds this connection.intgetReceiveQueue()Gets the size of the receive queue.InternetProtocolStats.TcpStategetState()Gets the connection state (TCP connections only).intgetTransmitQueue()Gets the size of the transmit queue.java.lang.StringgetType()Returns the connection protocol type, e.g., tcp4, tcp6, udp4, udp6java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
IPConnection
public IPConnection(java.lang.String type, byte[] localAddress, int localPort, byte[] foreignAddress, int foreignPort, InternetProtocolStats.TcpState state, int transmitQueue, int receiveQueue, int owningProcessId)
-
-
Method Details
-
getType
public java.lang.String getType()Returns the connection protocol type, e.g., tcp4, tcp6, udp4, udp6- Returns:
- The protocol type
-
getLocalAddress
public byte[] getLocalAddress()Gets the local address. For IPv4 addresses this is a 4-byte array. For IPv6 addresses this is a 16-byte array.On Unix operating systems, the 16-bit value may be truncated, giving only the high order bytes. IPv6 addresses ending in zeroes should be considered suspect.
- Returns:
- The local address, or an empty array if the listener can accept a connection on any interface.
-
getLocalPort
public int getLocalPort()Gets the local port.- Returns:
- The local port, or 0 if unknown, or any port.
-
getForeignAddress
public byte[] getForeignAddress()Gets the foreign/remote address. For IPv4 addresses this is a 4-byte array. For IPv6 addresses this is a 16-byte array.On Unix operating systems, this value may be truncated. IPv6 addresses ending in zeroes should be considered suspect.
- Returns:
- The foreign/remote address, or an empty array if unknown. An empty array will also result if
-
getForeignPort
public int getForeignPort()Gets the foreign/remote port.- Returns:
- The foreign/remote port, or 0 if unknown.
-
getState
Gets the connection state (TCP connections only).- Returns:
- The connection state if known or relevant, null otherwise.
-
getTransmitQueue
public int getTransmitQueue()Gets the size of the transmit queue. Not available on Windows.- Returns:
- The size of the transmit queue, or 0 if unknown.
-
getReceiveQueue
public int getReceiveQueue()Gets the size of the receive queue. Not available on Windows.- Returns:
- The size of the receive queue, or 0 if unknown.
-
getowningProcessId
public int getowningProcessId()Gets the id of the process which holds this connection.- Returns:
- The process id of the process which holds this connection if known, -1 otherwise.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-