Class UnixSocketStreamTransportMapping.ServerThread
java.lang.Object
org.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
org.snmp4j.transport.unix.UnixSocketStreamTransportMapping.ServerThread
- All Implemented Interfaces:
Runnable, org.snmp4j.util.WorkerTask
- Enclosing class:
UnixSocketStreamTransportMapping
protected class UnixSocketStreamTransportMapping.ServerThread
extends org.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
-
Field Summary
Fields inherited from class org.snmp4j.transport.AbstractTransportServerThread
exitLatch, lastError, pending, selector, serverAddress, shutdown, ssc, stop, transportMapping -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbindOutgoingSocket(SocketChannel socketChannel) Binds an outgoing socket to the socket path of this transport mapping, so that the peer this socket connects to can tell this SNMP entity apart from other entities that connect to it.protected UnixDomainAddresscreateIncomingAddress(SocketChannel socketChannel) createSocketEntry(UnixDomainAddress address, SocketChannel socketChannel, boolean useClientMode, org.snmp4j.TransportStateReference tmStateReference) protected ServerSocketChannelprotected booleaninitListener(UnixDomainAddress address, Selector selector) booleanisStop()booleanjoin(long timeout) protected SocketChannelopenSocketChannel(ProtocolFamily family) protected voidprotected booleanreadMessage(SelectionKey sk, SocketChannel socketChannel, UnixDomainAddress incomingAddress, UnixSocketStreamTransportMapping.SocketEntry socketEntry) removeSocketEntry(UnixDomainAddress incomingAddress) voidrun()voidsetStop(boolean stop) voidshutdown()Methods inherited from class org.snmp4j.transport.AbstractTransportServerThread
close, closeChannel, connectChannel, connectSocketToSendMessage, doServer, fireIncrementCounterSessionClose, getSelector, interrupt, join, sendMessage, terminate, writeData, writeMessage
-
Method Details
-
getLastError
-
isStop
public boolean isStop() -
setStop
public void setStop(boolean stop) -
getServerSocketChannel
-
initListener
- Throws:
IOException
-
run
public void run()- Specified by:
runin interfaceRunnable- Specified by:
runin classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
-
readMessage
protected boolean readMessage(SelectionKey sk, SocketChannel socketChannel, UnixDomainAddress incomingAddress, UnixSocketStreamTransportMapping.SocketEntry socketEntry) throws IOException - Specified by:
readMessagein classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>- Throws:
IOException
-
processQueues
protected void processQueues()- Specified by:
processQueuesin classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
-
createSocketEntry
public UnixSocketStreamTransportMapping.SocketEntry createSocketEntry(UnixDomainAddress address, SocketChannel socketChannel, boolean useClientMode, org.snmp4j.TransportStateReference tmStateReference) - Specified by:
createSocketEntryin classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
-
openSocketChannel
- Specified by:
openSocketChannelin classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>- Throws:
IOException
-
bindOutgoingSocket
Binds an outgoing socket to the socket path of this transport mapping, so that the peer this socket connects to can tell this SNMP entity apart from other entities that connect to it. A Unix domain socket that has not been bound has no address at all, thus every peer that connects without binding its socket is reported with the same empty address by the accepting entity - which then cannot address more than one of them.The socket is bound in client mode only: in server mode the socket path is already bound by the server socket that accepts incoming connections and a path can be bound once only. If the path cannot be bound - for example because another process is using it - the connection is opened with an unbound socket, because being unidentifiable to the peer is better than not being able to communicate with it at all.
- Parameters:
socketChannel- the outgoing socket to bind, must not be connected yet.- Throws:
IOException- if a socket file created by this transport mapping for an earlier connection could not be removed.- Since:
- 1.2.2
-
removeSocketEntry
public UnixSocketStreamTransportMapping.SocketEntry removeSocketEntry(UnixDomainAddress incomingAddress) - Specified by:
removeSocketEntryin classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>
-
createIncomingAddress
- Specified by:
createIncomingAddressin classorg.snmp4j.transport.AbstractTransportServerThread<UnixDomainAddress, UnixSocketStreamTransportMapping.SocketEntry>- Throws:
IOException
-
shutdown
public void shutdown() -
join
- Throws:
InterruptedException
-