Class UnixSocketStreamTransportMapping
java.lang.Object
org.snmp4j.transport.AbstractTransportMapping<UnixDomainAddress>
org.snmp4j.transport.AbstractConnectionOrientedTransportMapping<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
org.snmp4j.transport.unix.UnixSocketStreamTransportMapping
- All Implemented Interfaces:
Closeable, AutoCloseable, org.snmp4j.transport.ConnectionOrientedTransportMapping<UnixDomainAddress>, org.snmp4j.TransportMapping<UnixDomainAddress>
public class UnixSocketStreamTransportMapping
extends org.snmp4j.transport.AbstractConnectionOrientedTransportMapping<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
A transport mapping implementation for Unix domain socket communication that leverages
stream-oriented semantics. This class is built upon the AbstractConnectionOrientedTransportMapping,
providing enhanced support for Unix domain socket addresses.
The class allows for sending and receiving messages, setting socket options, and managing Unix domain socket communication-specific behaviors. It supports asynchronous message handling and can handle multiple concurrent Unix domain socket-based connections.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected UnixDomainAddressThe Unix domain socket address to which this transport mapping is bound.The server thread responsible for handling incoming connections.Fields inherited from class org.snmp4j.transport.AbstractConnectionOrientedTransportMapping
connectionTimeout, gracefulShutdownTimeoutMillis, serverEnabled, socketsFields inherited from class org.snmp4j.transport.AbstractTransportMapping
asyncMsgProcessingSupported, listenWorkerTask, maxInboundMessageSize, socketCleaner, suspendedAddresses, transportAuditListeners, transportListener, transportStateListeners -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a UnixSocketStreamTransportMapping without specifying a Unix domain socket address.UnixSocketStreamTransportMapping(UnixDomainAddress listenAddress) Constructs a UnixSocketStreamTransportMapping with the specified Unix domain socket address. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanclose(UnixDomainAddress remoteAddress) org.snmp4j.transport.MessageLengthDecoderClass<? extends org.snmp4j.smi.Address> booleanvoidlisten()protected Optional<ByteBuffer> readNextInPacket(SocketChannel socketChannel) Read the next network packet for the application.voidsendMessage(UnixDomainAddress address, byte[] message, org.snmp4j.TransportStateReference tmStateReference, long timeoutMillis, int maxRetries) voidsetMessageLengthDecoder(org.snmp4j.transport.MessageLengthDecoder messageLengthDecoder) protected <T> voidsetSocketOption(SocketOption<T> socketOption, T value) voidMethods inherited from class org.snmp4j.transport.AbstractConnectionOrientedTransportMapping
cancelNonServerSelectionKey, close, closeSockets, getConnectionTimeout, getGracefulShutdownTimeoutMillis, getMaxBusyLoops, getSockets, isServerEnabled, setConnectionTimeout, setGracefulShutdownTimeoutMillis, setMaxBusyLoops, setServerEnabled, setSocketOptions, timeoutSocketMethods inherited from class org.snmp4j.transport.AbstractTransportMapping
addTransportAuditListener, addTransportListener, addTransportStateListener, fireConnectionStateChanged, fireProcessMessage, fireTransportAuditEvent, getAuditListenAddress, getListenWorkerTask, getMaxInboundMessageSize, getPriority, getSocketCleaner, getSuspendedAddresses, getThreadName, handleDroppedMessageToSend, isAsyncMsgProcessingSupported, isTransportAudit, removeAllTransportAuditListeners, removeAllTransportListeners, removeTransportAuditListener, removeTransportListener, removeTransportStateListener, resumeAddress, setAsyncMsgProcessingSupported, setPriority, setThreadName, suspendAddressMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.snmp4j.transport.ConnectionOrientedTransportMapping
addTransportStateListener, getSocketCleaner, removeTransportStateListener, resumeAddress, suspendAddressMethods inherited from interface org.snmp4j.TransportMapping
addTransportListener, getMaxInboundMessageSize, getMaxOutboundMessageSize, getSupportedTransportType, isAddressSupported, isAddressSupported, removeTransportListener
-
Field Details
-
listenAddress
The Unix domain socket address to which this transport mapping is bound. -
serverThread
The server thread responsible for handling incoming connections.
-
-
Constructor Details
-
UnixSocketStreamTransportMapping
Constructs a UnixSocketStreamTransportMapping with the specified Unix domain socket address.- Parameters:
listenAddress- the Unix domain socket address to which this transport mapping is bound.
-
UnixSocketStreamTransportMapping
public UnixSocketStreamTransportMapping()Constructs a UnixSocketStreamTransportMapping without specifying a Unix domain socket address. This constructor is useful when the address will be set later.
-
-
Method Details
-
setSocketOption
- Specified by:
setSocketOptionin classorg.snmp4j.transport.AbstractConnectionOrientedTransportMapping<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>- Throws:
IOException
-
getMessageLengthDecoder
public org.snmp4j.transport.MessageLengthDecoder getMessageLengthDecoder() -
setMessageLengthDecoder
public void setMessageLengthDecoder(org.snmp4j.transport.MessageLengthDecoder messageLengthDecoder) -
getSupportedAddressClass
- Specified by:
getSupportedAddressClassin interfaceorg.snmp4j.TransportMapping<UnixDomainAddress>- Specified by:
getSupportedAddressClassin classorg.snmp4j.transport.AbstractTransportMapping<UnixDomainAddress>
-
getSupportedAddressClasses
-
getListenAddress
- Specified by:
getListenAddressin interfaceorg.snmp4j.TransportMapping<UnixDomainAddress>- Specified by:
getListenAddressin classorg.snmp4j.transport.AbstractTransportMapping<UnixDomainAddress>
-
sendMessage
public void sendMessage(UnixDomainAddress address, byte[] message, org.snmp4j.TransportStateReference tmStateReference, long timeoutMillis, int maxRetries) throws IOException - Specified by:
sendMessagein interfaceorg.snmp4j.TransportMapping<UnixDomainAddress>- Specified by:
sendMessagein classorg.snmp4j.transport.AbstractTransportMapping<UnixDomainAddress>- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.snmp4j.TransportMapping<UnixDomainAddress>- Overrides:
closein classorg.snmp4j.transport.AbstractConnectionOrientedTransportMapping<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>- Throws:
IOException
-
close
- Specified by:
closein interfaceorg.snmp4j.transport.ConnectionOrientedTransportMapping<UnixDomainAddress>- Overrides:
closein classorg.snmp4j.transport.AbstractConnectionOrientedTransportMapping<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>- Throws:
IOException
-
listen
- Specified by:
listenin interfaceorg.snmp4j.TransportMapping<UnixDomainAddress>- Specified by:
listenin classorg.snmp4j.transport.AbstractTransportMapping<UnixDomainAddress>- Throws:
IOException
-
isListening
public boolean isListening()- Specified by:
isListeningin interfaceorg.snmp4j.TransportMapping<UnixDomainAddress>- Overrides:
isListeningin classorg.snmp4j.transport.AbstractTransportMapping<UnixDomainAddress>
-
wakeupServerSelector
public void wakeupServerSelector()- Specified by:
wakeupServerSelectorin classorg.snmp4j.transport.AbstractConnectionOrientedTransportMapping<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
-
readNextInPacket
Read the next network packet for the application.- Parameters:
socketChannel- the socket channel to read the data from.- Returns:
- a byte buffer with the application data of the packet.
- Throws:
IOException- if there occurs an IO exception during preparation.- Since:
- 3.7
-