SNMP Stack 4_12

uk.co.westhawk.snmp.net
Class StandardSocket

java.lang.Object
  |
  +--uk.co.westhawk.snmp.net.StandardSocket
All Implemented Interfaces:
ContextSocketFace

public class StandardSocket
extends java.lang.Object
implements ContextSocketFace

This is a wrapper class around the standard DatagramSocket.

Version:
$Revision: 1.8 $ $Date: 2002/10/10 15:13:57 $
Author:
Tim Panton
See Also:
DatagramSocket

Fields inherited from interface uk.co.westhawk.snmp.net.ContextSocketFace
version_id
 
Constructor Summary
StandardSocket()
           
 
Method Summary
 void close()
          Closes this socket.
 void create(int port)
          Creates the socket.
 void create(java.lang.String host, int port)
          Creates the socket.
 java.lang.String getHostAddress()
          Returns the IP address of the host of the packet we received.
 java.io.ByteArrayInputStream receive(int maxRecvSize)
          Receives a packet from this socket.
 void send(byte[] packet)
          Sends a packet from this socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardSocket

public StandardSocket()
Method Detail

create

public void create(int port)
            throws java.io.IOException
Description copied from interface: ContextSocketFace
Creates the socket. This socket is used when listening for traps. Use only one (1) of the two create methods.
Specified by:
create in interface ContextSocketFace
Following copied from interface: uk.co.westhawk.snmp.net.ContextSocketFace
Parameters:
port - The local port number were we receive (listen for) packets.
See Also:
ContextSocketFace.create(String, int)

create

public void create(java.lang.String host,
                   int port)
            throws java.io.IOException
Description copied from interface: ContextSocketFace
Creates the socket. This socket is used to send out our requests. Use only one (1) of the two create methods.
Specified by:
create in interface ContextSocketFace
Following copied from interface: uk.co.westhawk.snmp.net.ContextSocketFace
Parameters:
host - The name of the host that is to receive our packets
port - The port number of the host
See Also:
ContextSocketFace.create(int)

getHostAddress

public java.lang.String getHostAddress()
Description copied from interface: ContextSocketFace
Returns the IP address of the host of the packet we received. This will be used when we are listening for traps.
Specified by:
getHostAddress in interface ContextSocketFace
Following copied from interface: uk.co.westhawk.snmp.net.ContextSocketFace
Returns:
The IP address, or null when the hostname cannot be determined

receive

public java.io.ByteArrayInputStream receive(int maxRecvSize)
                                     throws java.io.IOException
Description copied from interface: ContextSocketFace
Receives a packet from this socket.
Specified by:
receive in interface ContextSocketFace
Following copied from interface: uk.co.westhawk.snmp.net.ContextSocketFace
Parameters:
maxRecvSize - the maximum number of bytes to receive
Returns:
the packet as ByteArrayInputStream

send

public void send(byte[] packet)
          throws java.io.IOException
Description copied from interface: ContextSocketFace
Sends a packet from this socket.
Specified by:
send in interface ContextSocketFace
Following copied from interface: uk.co.westhawk.snmp.net.ContextSocketFace
Parameters:
packet - the packet

close

public void close()
Description copied from interface: ContextSocketFace
Closes this socket.
Specified by:
close in interface ContextSocketFace

SNMP Stack 4_12