com.act365.net
Class GeneralSocketImpl

java.lang.Object
  |
  +--java.net.SocketImpl
        |
        +--com.act365.net.GeneralSocketImpl
All Implemented Interfaces:
java.net.SocketOptions
Direct Known Subclasses:
TCPSocketImpl

public abstract class GeneralSocketImpl
extends java.net.SocketImpl

GeneralDatagramSocketImpl extends java.net.SocketImpl and provides native implementations of all of its abstract methods. The class remains abstract because it leaves its create() method undefined - it is up to subclasses to specify the parameters that will be used to create the underlying socket. The native code calls into the local Berkeley sockets implementation.


Fields inherited from interface java.net.SocketOptions
IP_MULTICAST_IF, SO_BINDADDR, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY
 
Constructor Summary
GeneralSocketImpl()
           
 
Method Summary
 void accept(java.net.SocketImpl newSocket)
          Accepts a connection request for this socket.
 int available()
          available() isn't supported.
 void bind(java.net.InetAddress inetAddress, int port)
          Binds this socket to the local port.
 void close()
          Closes this socket.
 void connect(java.net.InetAddress dst, int remotePort)
          Connects this socket to a given destination.
 void connect(java.net.SocketAddress address, int timeout)
          Connects to the specified host.
 void connect(java.lang.String hostName, int port)
          Connects this socket to a named host.
 void create(int socketType, int protocol)
          Creates a new unconnected TCP socket.
static java.net.InetAddress createInetAddress(int family, byte[] ipAddress)
          Creates a java.net.InetAddress object with a given IP address.
 java.io.InputStream getInputStream()
          Gets the input stream.
 java.lang.Object getOption(int optID)
          Gets the value of a socket option.
 java.io.OutputStream getOutputStream()
          Gets the output stream.
static int getSocketDescriptor(java.io.FileDescriptor fd)
          Gets the socket descriptor from a java.io.FileDescriptor object.
 void listen(int backlog)
          Listens for connection requests on this socket.
 void sendUrgentData(int data)
          Urgent data isn't supported.
 void setOption(int optID, java.lang.Object value)
          Sets the value of a socket option.The value has to be an Integer object.
static void setSocketDescriptor(java.io.FileDescriptor fd, int sd)
          Sets the socket descriptor for a java.io.FileDescriptor object.
 
Methods inherited from class java.net.SocketImpl
toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneralSocketImpl

public GeneralSocketImpl()
Method Detail

create

public void create(int socketType,
                   int protocol)
            throws java.io.IOException
Creates a new unconnected TCP socket.
Parameters:
socketType - the socket type as defined in SocketConstants e.g. SOCK_RAW
protocol - the protocol as defined in SocketConstants e.g. IPPROTO_UDP
See Also:
SocketConstants

bind

public void bind(java.net.InetAddress inetAddress,
                 int port)
          throws java.io.IOException
Binds this socket to the local port.
Parameters:
inetAddress - local IP address
port - number of the local port

connect

public void connect(java.lang.String hostName,
                    int port)
             throws java.io.IOException
Connects this socket to a named host.
Parameters:
hostName - name of the remote host
port - port number on the remote host

connect

public void connect(java.net.InetAddress dst,
                    int remotePort)
             throws java.io.IOException
Connects this socket to a given destination.
Parameters:
dst - address of the remote host
remotePort - port number on the remote host

connect

public void connect(java.net.SocketAddress address,
                    int timeout)
             throws java.io.IOException
Connects to the specified host.

listen

public void listen(int backlog)
            throws java.io.IOException
Listens for connection requests on this socket.
Parameters:
backlog - maxmimum number of pending requests to be serviced simultaneously

accept

public void accept(java.net.SocketImpl newSocket)
            throws java.io.IOException
Accepts a connection request for this socket.
Parameters:
newSocket - socket to be populated with the details of the remote client

close

public void close()
           throws java.io.IOException
Closes this socket.

getSocketDescriptor

public static int getSocketDescriptor(java.io.FileDescriptor fd)
Gets the socket descriptor from a java.io.FileDescriptor object. NB Java provides no public access to the value of the descriptor so it has to be extracted using native code.

setSocketDescriptor

public static void setSocketDescriptor(java.io.FileDescriptor fd,
                                       int sd)
Sets the socket descriptor for a java.io.FileDescriptor object. NB Java provides no public access to the descriptor so its value has to be set using native code.

createInetAddress

public static java.net.InetAddress createInetAddress(int family,
                                                     byte[] ipAddress)
Creates a java.net.InetAddress object with a given IP address.
Parameters:
family - the socket family - normally SocketConstants.AF_INET
ipAddress - the IP address e.g. new byte[] { 127, 0, 0, 1 }

setOption

public void setOption(int optID,
                      java.lang.Object value)
               throws java.net.SocketException
Sets the value of a socket option.The value has to be an Integer object.
Overrides:
setOption in class java.net.SocketImpl
Parameters:
optID - option as defined in java.net.SocketConstants
value - an Integer object that wraps the new value

getOption

public java.lang.Object getOption(int optID)
                           throws java.net.SocketException
Gets the value of a socket option. The returned value will be an Integer object.
Overrides:
getOption in class java.net.SocketImpl
Parameters:
optID - option as defined in java.net.SocketConstants

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Gets the output stream.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Gets the input stream.

available

public int available()
              throws java.io.IOException
available() isn't supported.

sendUrgentData

public void sendUrgentData(int data)
                    throws java.io.IOException
Urgent data isn't supported.