01: /*_############################################################################
02: _##
03: _## SNMP4J - ConnectionOrientedTransportMapping.java
04: _##
05: _## Copyright (C) 2003-2008 Frank Fock and Jochen Katz (SNMP4J.org)
06: _##
07: _## Licensed under the Apache License, Version 2.0 (the "License");
08: _## you may not use this file except in compliance with the License.
09: _## You may obtain a copy of the License at
10: _##
11: _## http://www.apache.org/licenses/LICENSE-2.0
12: _##
13: _## Unless required by applicable law or agreed to in writing, software
14: _## distributed under the License is distributed on an "AS IS" BASIS,
15: _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: _## See the License for the specific language governing permissions and
17: _## limitations under the License.
18: _##
19: _##########################################################################*/
20:
21: package org.snmp4j.transport;
22:
23: import org.snmp4j.*;
24: import org.snmp4j.smi.Address;
25: import java.io.IOException;
26:
27: /**
28: * Transport mappings for connection oriented transport protocols have to
29: * implement this interface.
30: *
31: * @author Frank Fock
32: * @version 1.7.1
33: * @since 1.7
34: */
35: public interface ConnectionOrientedTransportMapping extends
36: TransportMapping {
37:
38: /**
39: * Returns the <code>MessageLengthDecoder</code> used by this transport
40: * mapping.
41: * @return
42: * a MessageLengthDecoder instance.
43: */
44: MessageLengthDecoder getMessageLengthDecoder();
45:
46: /**
47: * Sets the <code>MessageLengthDecoder</code> that decodes the total
48: * message length from the header of a message.
49: *
50: * @param messageLengthDecoder
51: * a MessageLengthDecoder instance.
52: */
53: void setMessageLengthDecoder(
54: MessageLengthDecoder messageLengthDecoder);
55:
56: /**
57: * Sets the connection timeout. This timeout specifies the time a connection
58: * may be idle before it is closed.
59: * @param connectionTimeout
60: * the idle timeout in milliseconds. A zero or negative value will disable
61: * any timeout and connections opened by this transport mapping will stay
62: * opened until they are explicitly closed.
63: */
64: void setConnectionTimeout(long connectionTimeout);
65:
66: /**
67: * Adds a transport state listener that is to be informed about connection
68: * state changes.
69: * @param l
70: * a TransportStateListener.
71: */
72: void addTransportStateListener(TransportStateListener l);
73:
74: /**
75: * Removes the supplied transport state listener.
76: * @param l
77: * a TransportStateListener.
78: */
79: void removeTransportStateListener(TransportStateListener l);
80:
81: /**
82: * Closes the connection to the given remote address (socket).
83: * @param remoteAddress
84: * the address of the remote socket.
85: * @return
86: * <code>true</code> if the connection could be closed and
87: * <code>false</code> if either the connection does not exists.
88: * @since 1.7.1
89: */
90: boolean close(Address remoteAddress) throws IOException;
91:
92: }
|