Class powersoft.jcm.net.BaseSocket
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class powersoft.jcm.net.BaseSocket

java.lang.Object
   |
   +----powersoft.jcm.net.BaseSocket

public class BaseSocket
extends Object
implements SocketExceptionCode
This class serves as the abstract base class for the ServerSocket and Socket classes.
See Also:
Socket, ServerSocket

Variable Index

 o _asynchronous
 o _created
 o _errorVector
 o _getHostByNameThread
 o _hostResolvedVector
 o _localPort
 o _remoteAddr
 o _remotePort
 o _root

Constructor Index

 o BaseSocket()
Instantiates a BaseSocket object.

Method Index

 o addSocketErrorListener(SocketErrorListener)
 o addSocketHostResolvedListener(SocketHostResolvedListener)
 o close()
Closes the socket.
 o getAsynchronous()
Determines whether the socket is asynchronous or not.
 o getLastError()
Gets the error code of the last operation on the socket that failed.
 o getLocalHostAddress()
Gets the internet address of the local host for the socket.
 o getLocalHostName()
Gets the name of the local host for the socket.
 o getLocalPort()
Gets the local port used by the socket.
 o getRemoteHostName()
Gets the name of the remote host for a connected stream socket.
 o getRemoteInetAddress()
Gets the internet address of the remote host for a connected stream socket.
 o getRemotePort()
Gets the port of the remote host for a connected stream socket.
 o getSocketErrorListeners()
 o getSocketHostResolvedListeners()
 o handleSocketError(SocketErrorEvent)
SocketErrorEvent handler
 o handleSocketHostResolved(SocketHostResolvedEvent)
SocketHostResolvedEvent handler
 o RaiseError(byte)
 o RaiseError(byte, Exception)
 o removeSocketErrorListener(SocketErrorListener)
 o removeSocketHostResolvedListener(SocketHostResolvedListener)
 o ResetAsynchronous(boolean)
 o resetLastError()
Resets the error code of the last operation on the socket that failed to SockENoError.
 o ResetLocalPort(int)
 o ResetRemotePort(int)
 o setAsynchronous(boolean)
Sets the mode of the socket to asynchronous or non-asynchronous.
 o setLocalPort(int)
Sets the local port to be used by the socket.
 o setRemoteHostName(String)
Sets the name of the remote host in preparation of a connect operation on a stream socket.
 o setRemotePort(int)
Sets the port of the remote host in preparation of a connect operation on a stream socket.

Variables

 o _asynchronous
  protected boolean _asynchronous
 o _created
  protected boolean _created
 o _remoteAddr
  protected InetAddress _remoteAddr
 o _remotePort
  protected int _remotePort
 o _localPort
  protected int _localPort
 o _root
  protected BaseSocket _root
 o _getHostByNameThread
  protected GetHostByNameThread _getHostByNameThread
 o _hostResolvedVector
  protected EventListenerVector _hostResolvedVector
 o _errorVector
  protected EventListenerVector _errorVector

Constructors

 o BaseSocket
  protected BaseSocket()
Instantiates a BaseSocket object. This is to be used by the ServerSocket and Socket classes only

Methods

 o addSocketErrorListener
  public synchronized void addSocketErrorListener(SocketErrorListener l)
 o getSocketErrorListeners
  public synchronized EventListenerVector getSocketErrorListeners()
 o handleSocketError
  public synchronized void handleSocketError(SocketErrorEvent data)
SocketErrorEvent handler
 o removeSocketErrorListener
  public synchronized void removeSocketErrorListener(SocketErrorListener l)
 o addSocketHostResolvedListener
  public synchronized void addSocketHostResolvedListener(SocketHostResolvedListener l)
 o getSocketHostResolvedListeners
  public synchronized EventListenerVector getSocketHostResolvedListeners()
 o handleSocketHostResolved
  public synchronized void handleSocketHostResolved(SocketHostResolvedEvent data)
SocketHostResolvedEvent handler
 o removeSocketHostResolvedListener
  public synchronized void removeSocketHostResolvedListener(SocketHostResolvedListener l)
 o getAsynchronous
  public boolean getAsynchronous()
Determines whether the socket is asynchronous or not. An asynchronous socket triggers events in notification of network events. A non- asynchronous socket has operations which block while waiting for network events.
Returns:
true if the socket is asynchronous, false if it is non-asynchronous.
See Also:
setAsynchronous, setRemoteHostName, connect
 o setAsynchronous
  public synchronized void setAsynchronous(boolean value)
Sets the mode of the socket to asynchronous or non-asynchronous.

Notes: The socket must be created before setting this property. If not, the LastError property is set to SockENotCreated.

Parameters:
value - If true, the socket is set to be asynchronous. If false, the socket is set to be non-asynchronous.
See Also:
getAsynchronous
 o getLastError
  public int getLastError()
Gets the error code of the last operation on the socket that failed.
Returns:
The error code of the last operation on the socket that failed.
See Also:
SocketExceptionCode
 o getLocalHostAddress
  public static byte[] getLocalHostAddress()
Gets the internet address of the local host for the socket.

Notes: If the local host is unknown, null is returned and the LastError property is set to SockEUnknownHost.

Returns:
The internet IP address as an array of bytes, with the highest- order byte as the first element of the array.
See Also:
SocketExceptionCode, getLocalHostName
 o getLocalHostName
  public static String getLocalHostName()
Gets the name of the local host for the socket.

Notes: If the local host is unknown, null is returned and the LastError property is set to SockEUnknownHost.

Returns:
The name of the local host.
See Also:
SocketExceptionCode, getLocalHostAddress
 o getLocalPort
  public int getLocalPort()
Gets the local port used by the socket.

Notes: The socket must be created before getting this property. If not, the LastError property is set to SockENotCreated.

A connection-based socket should not set the local port. Rather, the local port is determined at connection time.

Returns:
The local port number in use by the socket.
See Also:
SocketExceptionCode, setLocalPort
 o setLocalPort
  public synchronized void setLocalPort(int port)
Sets the local port to be used by the socket.

Notes: The socket must be created before setting this property. If not, the LastError property is set to SockENotCreated.

If the local port is not set, or set to 0, then a free port is assigned by the system.

Parameters:
port - The local port number to be used by the socket.
See Also:
SocketExceptionCode, getLocalPort
 o getRemoteHostName
  public String getRemoteHostName()
Gets the name of the remote host for a connected stream socket.

Notes: The socket must be created before getting this property. If not, the LastError property is set to SockENotCreated.

If the remote host is unknown, null is returned.

Returns:
The name of the remote host to which the socket is connected.
See Also:
SocketExceptionCode, setRemoteHostName
 o setRemoteHostName
  public synchronized void setRemoteHostName(String name)
Sets the name of the remote host in preparation of a connect operation on a stream socket.

Notes: The socket must be created before setting this property. If not, the LastError property is set to SockENotCreated.

If the socket is non-asynchronous, this method blocks while the remote host name is resolved.

If the socket is asynchronous, this method returns immediately, however, getRemoteHostName will not return the correct name until the SocketHostResolved event has been triggered.

If the remote host cannot be resolved, the RemoteHostName property is set to null is and the LastError property is set to SockEUnknownHost.

Parameters:
name - The name of the remote host to which the socket is to be connected.
See Also:
SocketExceptionCode, getRemoteHostName, connect
 o getRemoteInetAddress
  public byte[] getRemoteInetAddress()
Gets the internet address of the remote host for a connected stream socket.

Notes: The socket must be created before getting this property. If not, the LastError property is set to SockENotCreated and null is returned.

If the remote host has not been set, the LastError property is set to SockERemoteHostNotSet and null is returned.

Returns:
The internet IP address of the remote host as an array of bytes, with the highest-order byte as the first element of the array.
See Also:
SocketExceptionCode, getRemoteHostName
 o getRemotePort
  public int getRemotePort()
Gets the port of the remote host for a connected stream socket.

Notes: The socket must be created before getting this property. If not, the LastError property is set to SockENotCreated and 0 is returned.

A server socket should not set the remote port. Rather, the remote port is determined upon a call to accept.

Returns:
The port of the remote host to which the socket is connected.
See Also:
SocketExceptionCode, setRemotePort
 o setRemotePort
  public synchronized void setRemotePort(int port)
Sets the port of the remote host in preparation of a connect operation on a stream socket.

Notes: The socket must be created before setting this property. If not, the LastError property is set to SockENotCreated.

Setting this property on a socket that is already connected will cause the socket to be closed, then re-connected.

Parameters:
port - the port of the remote host to which the socket is to be connected.
See Also:
SocketExceptionCode, getRemotePort, connect
 o resetLastError
  public synchronized void resetLastError()
Resets the error code of the last operation on the socket that failed to SockENoError.
See Also:
SocketExceptionCode
 o close
  public abstract boolean close()
Closes the socket.
 o ResetLocalPort
  protected abstract boolean ResetLocalPort(int port)
 o ResetRemotePort
  protected abstract boolean ResetRemotePort(int port)
 o ResetAsynchronous
  protected abstract boolean ResetAsynchronous(boolean value)
 o RaiseError
  protected void RaiseError(byte error)
 o RaiseError
  protected void RaiseError(byte error,
                            Exception exception)

All Packages  Class Hierarchy  This Package  Previous  Next  Index