java.lang.Object
oshi.software.os.InternetProtocolStats.IPConnection
- Enclosing interface:
- InternetProtocolStats
Encapsulates information associated with an IP connection.
-
Constructor Summary
ConstructorDescriptionIPConnection
(String type, byte[] localAddress, int localPort, byte[] foreignAddress, int foreignPort, InternetProtocolStats.TcpState state, int transmitQueue, int receiveQueue, int owningProcessId) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Gets the foreign/remote address.int
Gets the foreign/remote port.byte[]
Gets the local address.int
Gets the local port.int
Gets the id of the process which holds this connection.int
Gets the size of the receive queue.getState()
Gets the connection state (TCP connections only).int
Gets the size of the transmit queue.getType()
Returns the connection protocol type, e.g., tcp4, tcp6, tcp46, udp4, udp6, udp46toString()
-
Constructor Details
-
IPConnection
public IPConnection(String type, byte[] localAddress, int localPort, byte[] foreignAddress, int foreignPort, InternetProtocolStats.TcpState state, int transmitQueue, int receiveQueue, int owningProcessId)
-
-
Method Details
-
getType
Returns the connection protocol type, e.g., tcp4, tcp6, tcp46, udp4, udp6, udp46- 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
-