SNMP Stack 5_1

uk.co.westhawk.snmp.net
Interface ContextSocketFace

All Known Implementing Classes:
KvmSocket, NetscapeSocket, StandardSocket, TCPSocket

public interface ContextSocketFace

The interface for the different type of sockets.

Version:
$Revision: 1.12 $ $Date: 2006/02/09 14:30:19 $
Author:
Tim Panton

Field Summary
static java.lang.String version_id
           
 
Method Summary
 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.
 

Field Detail

version_id

public static final java.lang.String version_id
See Also:
Constant Field Values
Method Detail

create

public void create(int port,
                   java.lang.String bindAddr)
            throws java.io.IOException
Creates the socket. This socket is used when listening for incoming requests or traps. Use only one (1) of the two create methods.

Parameters:
port - The local port number were we receive (listen for) packets
bindAddr - The local address the server will bind to when listening
java.io.IOException
See Also:
create(String, int, String)

create

public void create(java.lang.String host,
                   int port,
                   java.lang.String bindAddr)
            throws java.io.IOException
Creates the socket. This socket is used to send out our requests. Use only one (1) of the two create methods.

Parameters:
host - The name of the host that is to receive our packets
port - The port number of the host
bindAddr - The local address the server will bind to when sending packets
java.io.IOException
See Also:
create(int, String)

getSendToHostAddress

public java.lang.String getSendToHostAddress()
Returns the IP address of the host we sent the packet to. Only applicable when sending requests, not when (only) listening for incoming requests or traps.

Returns:
The IP address, or null when the hostname cannot be determined
See Also:
getReceivedFromHostAddress()

getReceivedFromHostAddress

public java.lang.String getReceivedFromHostAddress()
Returns the IP address of the (latest) host of the packet we received. Only applicable when anything has been received. When sending a request, this will in most cases be the same host where we sent the original packet to.

Returns:
The IP address, or null when the hostname cannot be determined
See Also:
getSendToHostAddress()

getLocalSocketAddress

public java.lang.String getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.

Since:
4_14

getRemoteSocketAddress

public java.lang.String getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or null if it is unconnected.

Since:
4_14

receive

public StreamPortItem receive(int maxRecvSize)
                       throws java.io.IOException
Receives a packet from this socket. The StreamPortItem object contains the host and port the packet came from.

Parameters:
maxRecvSize - the maximum number of bytes to receive
Returns:
the packet
java.io.IOException

send

public void send(byte[] packet)
          throws java.io.IOException
Sends a packet from this socket. It can throw an "java.io.IOException: Invalid argument" when the bind address is incorrect for some reason.

Parameters:
packet - the packet
java.io.IOException

close

public void close()
Closes this socket.


SNMP Stack 5_1