public class TCPSocket extends java.lang.Object implements ContextSocketFace
This is part of what is called "Reliable SNMP". SNMP usually goes over UDP. That is why there is a retry mechanisme in SNMP. Sending SNMP over TCP will only work is your agent listens on TCP. See RFC 3430
When listening for incoming packets, the Socket, that is created when accepting an incoming connection, is closed at the end. Because of this, it is NOT possible to send a response back over the same connection.
Socket| Constructor and Description |
|---|
TCPSocket() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this socket.
|
void |
create(int port,
java.lang.String bindAddr)
Creates the socket.
|
void |
create(java.lang.String host,
int port,
java.lang.String bindAddr)
Creates the socket.
|
java.lang.String |
getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null
if it is not bound yet.
|
java.lang.String |
getReceivedFromHostAddress()
Returns the IP address of the (latest) host of the packet we received.
|
java.lang.String |
getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or
null if it is unconnected.
|
java.lang.String |
getSendToHostAddress()
Returns the IP address of the host we sent the packet to.
|
StreamPortItem |
receive(int maxRecvSize)
Receives a packet from this socket.
|
void |
send(byte[] packet)
Sends a packet from this socket.
|
public void create(int port,
java.lang.String bindAddr)
throws java.io.IOException
ContextSocketFacecreate in interface ContextSocketFaceport - The local port number were we receive (listen for)
packetsbindAddr - The local address the server will bind to when
listeningjava.io.IOExceptionContextSocketFace.create(String, int, String)public void create(java.lang.String host,
int port,
java.lang.String bindAddr)
throws java.io.IOException
ContextSocketFacecreate in interface ContextSocketFacehost - The name of the host that is to receive our packetsport - The port number of the hostbindAddr - The local address the server will bind to when
sending packetsjava.io.IOExceptionContextSocketFace.create(int, String)public java.lang.String getReceivedFromHostAddress()
ContextSocketFacegetReceivedFromHostAddress in interface ContextSocketFaceContextSocketFace.getSendToHostAddress()public java.lang.String getSendToHostAddress()
ContextSocketFacegetSendToHostAddress in interface ContextSocketFaceContextSocketFace.getReceivedFromHostAddress()public java.lang.String getLocalSocketAddress()
ContextSocketFacegetLocalSocketAddress in interface ContextSocketFacepublic java.lang.String getRemoteSocketAddress()
ContextSocketFacegetRemoteSocketAddress in interface ContextSocketFacepublic StreamPortItem receive(int maxRecvSize) throws java.io.IOException
ContextSocketFacereceive in interface ContextSocketFacemaxRecvSize - the maximum number of bytes to receivejava.io.IOExceptionpublic void send(byte[] packet)
throws java.io.IOException
ContextSocketFacesend in interface ContextSocketFacepacket - the packetjava.io.IOExceptionpublic void close()
ContextSocketFaceclose in interface ContextSocketFace