Package uk.co.westhawk.snmp.net
Class StandardSocket
java.lang.Object
uk.co.westhawk.snmp.net.StandardSocket
- All Implemented Interfaces:
 ContextSocketFace
This is a wrapper class around the standard DatagramSocket. This
 sends packets over UDP, which is standard in SNMP.
- Version:
 - $Revision: 1.13 $ $Date: 2009/03/05 15:56:19 $
 - Author:
 - Tim Panton
 - See Also:
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this socket.voidCreates the socket.voidCreates the socket.Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.Returns the IP address of the (latest) host of the packet we received.Returns the address of the endpoint this socket is connected to, or null if it is unconnected.Returns the IP address of the host we sent the packet to.receive(int maxRecvSize) Receives a packet from this socket.voidsend(byte[] packet) Sends a packet from this socket. 
- 
Constructor Details
- 
StandardSocket
public StandardSocket() 
 - 
 - 
Method Details
- 
create
Description copied from interface:ContextSocketFaceCreates the socket. This socket is used when listening for incoming requests or traps. Use only one (1) of the two create methods.- Specified by:
 createin interfaceContextSocketFace- Parameters:
 port- The local port number were we receive (listen for) packetsbindAddr- The local address the server will bind to when listening- Throws:
 IOException- See Also:
 
 - 
create
Description copied from interface:ContextSocketFaceCreates the socket. This socket is used to send out our requests. Use only one (1) of the two create methods.- Specified by:
 createin interfaceContextSocketFace- Parameters:
 host- 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 packets- Throws:
 IOException- See Also:
 
 - 
getReceivedFromHostAddress
Description copied from interface:ContextSocketFaceReturns 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.- Specified by:
 getReceivedFromHostAddressin interfaceContextSocketFace- Returns:
 - The IP address, or null when the hostname cannot be determined
 - See Also:
 
 - 
getSendToHostAddress
Description copied from interface:ContextSocketFaceReturns 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.- Specified by:
 getSendToHostAddressin interfaceContextSocketFace- Returns:
 - The IP address, or null when the hostname cannot be determined
 - See Also:
 
 - 
getLocalSocketAddress
Description copied from interface:ContextSocketFaceReturns the address of the endpoint this socket is bound to, or null if it is not bound yet.- Specified by:
 getLocalSocketAddressin interfaceContextSocketFace
 - 
getRemoteSocketAddress
Description copied from interface:ContextSocketFaceReturns the address of the endpoint this socket is connected to, or null if it is unconnected.- Specified by:
 getRemoteSocketAddressin interfaceContextSocketFace
 - 
receive
Description copied from interface:ContextSocketFaceReceives a packet from this socket. The StreamPortItem object contains the host and port the packet came from.- Specified by:
 receivein interfaceContextSocketFace- Parameters:
 maxRecvSize- the maximum number of bytes to receive- Returns:
 - the packet
 - Throws:
 IOException
 - 
send
Description copied from interface:ContextSocketFaceSends a packet from this socket. It can throw an "java.io.IOException: Invalid argument" when the bind address is incorrect for some reason.- Specified by:
 sendin interfaceContextSocketFace- Parameters:
 packet- the packet- Throws:
 IOException
 - 
close
public void close()Description copied from interface:ContextSocketFaceCloses this socket.- Specified by:
 closein interfaceContextSocketFace
 
 -