Package java.net |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public abstract class java.net.SocketImpl extends java.lang.Object { // Fields protected InetAddress address; protected FileDescriptor fd; protected int localport; protected int port; // Constructors public SocketImpl(); // Methods protected abstract void accept(SocketImpl s); protected abstract int available(); protected abstract void bind(InetAddress host, int port); protected abstract void close(); protected abstract void connect(InetAddress address, int port); protected abstract void connect(String host, int port); protected abstract void create(boolean stream); protected FileDescriptor getFileDescriptor(); protected InetAddress getInetAddress(); protected abstract InputStream getInputStream(); protected int getLocalPort(); protected abstract OutputStream getOutputStream(); protected int getPort(); protected abstract void listen(int count); public String toString(); }
The abstract class SocketImpl is a common superclass of all classes that actually implement sockets. It is used to create both client and server sockets.
A "plain" socket implements these methods exactly as described, without attempting to go through a firewall or proxy.
protected InetAddress addressThe IP address of the remote end of this socket.
protected FileDescriptor fdThe file descriptor object for this socket.
protected int localportThe local port number to which this socket is connected
protected int portThe port number on the remote host to which this socket is connected.
public SocketImpl()The default constructor for a socket implementation.
protected abstract void accept(SocketImpl s)throws IOExceptionAccepts a connection.
Parameter Description s the accepted connection Throw:
If an I/O error occurs when accepting the connection.
protected abstract int available()throws IOExceptionReturn Value:
Returns the number of bytes that can be read from this socket without blocking.
Throw:
If an I/O error occurs when determining the number of bytes available.
protected abstract void bind(InetAddress host, int port)throws IOExceptionBinds this socket to the specified port number on the specified host.
Parameter Description host the IP address of the remote hsot port the port number Throw:
If an I/O error occurs when binding this socket.
protected abstract void close()throws IOExceptionCloses this socket.
Throw:
If an I/O error occurs when closing this socket.
protected abstract void connect(InetAddress address, int port)throws IOExceptionConnects this socket to the specified port number on the specified host.
Parameter Description address the IP address of the remote host port the port number Throw:
If an I/O error occurs when attempting a connection.
protected abstract void connect(String host, int port)throws IOExceptionConnects this socket to the specified port on the named host.
Parameter Description host the name of the remote host port the port number Throw:
If an I/O error occurs when connecting to the remote host.
protected abstract void create(boolean stream)throws IOExceptionCreates a socket.
Parameter Description stream if true, create a stream socket; otherwise, create a datagram socket Throw:
If an IO error occurs while creating the socket.
protected FileDescriptor getFileDescriptor()Return Value:
Returns the value of this socket's fd field .
protected InetAddress getInetAddress()Return Value:
Returns the value of this socket's address field .
protected abstract InputStream getInputStream()throws IOExceptionReturn Value:
Returns a stream for reading from this socket.
Throw:
If an I/O error occurs when creating the input stream.
protected int getLocalPort()Return Value:
Returns the value of this socket's localport field .
protected abstract OutputStream getOutputStream()throws IOExceptionReturn Value:
Returns an output stream for writing to this socket.
Throw:
If an I/O error occurs when creating the output stream.
protected int getPort()Return Value:
Returns the value of this socket's port field .
protected abstract void listen(int count)throws IOExceptionSets the maximum queue length for incoming requests to this socket to the count argument. If a connection request arrives when the queue is full, the connection is refused.
Parameter Description count the maximum length of the queue Throw:
If an I/O error occurs when creating the queue..
public String toString()Return Value:
Returns a string representation of this socket.
Overrides:
toString in class Object .