Package java.net Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class SocketImpl

Fields , Constructors , Methods

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.


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.

ParameterDescription
s the accepted connection

Throw:

IOException

If an I/O error occurs when accepting the connection.


available

protected abstract int available() 
throws IOException 

Return Value:

Returns the number of bytes that can be read from this socket without blocking.

Throw:

IOException

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.

ParameterDescription
host the IP address of the remote hsot
port the port number

Throw:

IOException

If an I/O error occurs when binding this socket.


close

protected abstract void close() 
throws IOException 

Closes this socket.

Throw:

IOException

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.

ParameterDescription
address the IP address of the remote host
port the port number

Throw:

IOException

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.

ParameterDescription
host the name of the remote host
port the port number

Throw:

IOException

If an I/O error occurs when connecting to the remote host.


create

protected abstract void create(boolean  stream) 
throws IOException 

Creates a socket.

ParameterDescription
stream if true, create a stream socket; otherwise, create a datagram socket

Throw:

IOException

If an IO error occurs while creating the socket.


getFileDescriptor

protected FileDescriptor getFileDescriptor() 

Return Value:

Returns the value of this socket's fd field .


getInetAddress

protected InetAddress getInetAddress() 

Return Value:

Returns the value of this socket's address field .


getInputStream

protected abstract InputStream getInputStream() 
throws IOException 

Return Value:

Returns a stream for reading from this socket.

Throw:

IOException

If an I/O error occurs when creating the input stream.


getLocalPort

protected int getLocalPort() 

Return Value:

Returns the value of this socket's localport field .


getOutputStream

protected abstract OutputStream getOutputStream() 
throws IOException 

Return Value:

Returns an output stream for writing to this socket.

Throw:

IOException

If an I/O error occurs when creating the output stream.


getPort

protected int getPort() 

Return Value:

Returns the value of this socket's port field .


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.

ParameterDescription
count the maximum length of the queue

Throw:

IOException

If an I/O error occurs when creating the queue..


toString

public String toString() 

Return Value:

Returns a string representation of this socket.

Overrides:

toString in class Object .



Top© 1996 Sun Microsystems, Inc. All rights reserved.