Packages  This Package  Prev  Next  Index  

§4.7 Class SocketImpl

public  abstract  class  java.net.SocketImpl
    extends  java.lang.Object  (I-§1.12)
{
        // Fields
    protected InetAddress address;	§4.7.1
    protected FileDescriptor fd;	§4.7.2
    protected int localport;	§4.7.3
    protected int port;	§4.7.4

        // Constructors
    public SocketImpl();	§4.7.5

        // Methods
    protected abstract void accept(SocketImpl  s);	§4.7.6
    protected abstract int available();	§4.7.7
    protected abstract void bind(InetAddress  host, int  port);	§4.7.8
    protected abstract void close();	§4.7.9
    protected abstract void	§4.7.10
        connect(InetAddress  address, int  port);
    protected abstract void connect(String  host, int  port);	§4.7.11
    protected abstract void create(boolean  stream);	§4.7.12
    protected FileDescriptor getFileDescriptor();	§4.7.13
    protected InetAddress getInetAddress();	§4.7.14
    protected abstract InputStream getInputStream();	§4.7.15
    protected int getLocalPort();	§4.7.16
    protected abstract OutputStream getOutputStream();	§4.7.17
    protected int getPort();	§4.7.18
    protected abstract void listen(int  count);	§4.7.19
    public String toString();	§4.7.20
}
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.


Fields

address

protected InetAddress address
The IP address of the remote end of this socket.

fd

protected FileDescriptor fd
The file descriptor object for this socket.

localport

protected int localport
The local port number to which this socket is connected

port

protected int port
The port number on the remote host to which this socket is connected.

Constructors

SocketImpl

public SocketImpl()
The default constructor for a socket implementation.

Methods

accept

protected abstract void accept(SocketImpl s) throws IOException
Accepts a connection.
Parameters:
s - the accepted connection
Throws
IOException (I-§2.29)
If an I/O error occurs when accepting the connection.

available

protected abstract int available() throws IOException
Returns:
the number of bytes that can be read from this socket without blocking.
Throws
IOException (I-§2.29)
If an I/O error occurs when determining the number of bytes available.

bind

protected abstract void bind(InetAddress host, int port) throws IOException
Binds this socket to the specified port number on the specified host.
Parameters:
host - the IP address of the remote hsot
port - the port number
Throws
IOException (I-§2.29)
If an I/O error occurs when binding this socket.

close

protected abstract void close() throws IOException
Closes this socket.
Throws
IOException (I-§2.29)
If an I/O error occurs when closing this socket.

connect

protected abstract void
connect(InetAddress address, int port)
throws IOException
Connects this socket to the specified port number on the specified host.
Parameters:
address - the IP address of the remote host
port - the port number
Throws
IOException (I-§2.29)
If an I/O error occurs when attempting a connection.

connect

protected abstract void connect(String host, int port) throws IOException
Connects this socket to the specified port on the named host.
Parameters:
host - the name of the remote host
port - the port number
Throws
IOException (I-§2.29)
If an I/O error occurs when connecting to the remote host.

create

protected abstract void create(boolean stream) throws IOException
Creates a socket.
Parameters:
stream - if true, create a stream socket; otherwise, create a datagram socket
Throws
IOException (I-§2.29)
If an IO error occurs while creating the socket.

getFileDescriptor

protected FileDescriptor getFileDescriptor()
Returns:
the value of this socket's fd field (I-§4.7.2).

getInetAddress

protected InetAddress getInetAddress()
Returns:
the value of this socket's address field (I-§4.7.1).

getInputStream

protected abstract InputStream getInputStream() throws IOException
Returns:
a stream for reading from this socket.
Throws
IOException (I-§2.29)
If an I/O error occurs when creating the input stream.

getLocalPort

protected int getLocalPort()
Returns:
the value of this socket's localport field (I-§4.7.3).

getOutputStream

protected abstract OutputStream getOutputStream() throws IOException
Returns:
an output stream for writing to this socket.
Throws
IOException (I-§2.29)
If an I/O error occurs when creating the output stream.

getPort

protected int getPort()
Returns:
the value of this socket's port field (I-§4.7.4).

listen

protected abstract void listen(int count) throws IOException
Sets 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.
Parameters:
count - the maximum length of the queue
Throws
IOException (I-§2.29)
If an I/O error occurs when creating the queue..

toString

public String toString()
Returns:
a string representation of this socket.
Overrides:
toString in class Object (I-§1.12.9).

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com