/[classpath]/classpath/java/net/SocketImpl.java
ViewVC logotype

Diff of /classpath/java/net/SocketImpl.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.8 by ericb, Sat Feb 9 23:22:04 2002 UTC
# Line 1  Line 1 
1  /* SocketImpl.java -- Abstract socket implementation class  /* SocketImpl.java -- Abstract socket implementation class
2     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 39  package java.net; Line 39  package java.net;
39    
40  import java.io.*;  import java.io.*;
41    
42   /* Written using on-line Java Platform 1.2 API Specification.  /* Written using on-line Java Platform 1.2 API Specification.
43    * Believed complete and correct.   * Believed complete and correct.
44    */   */
45    
46    /**  /**
47     * This abstract class serves as the parent class for socket implementations.   * This abstract class serves as the parent class for socket implementations.
48     * The implementation class serves an intermediary to native routines that   * The implementation class serves an intermediary to native routines that
49     * perform system specific socket operations.   * perform system specific socket operations.
50     * <p>   * <p>
51     * A default implementation is provided by the system, but this can be   * A default implementation is provided by the system, but this can be
52     * changed via installing a <code>SocketImplFactory</code> (through a call   * changed via installing a <code>SocketImplFactory</code> (through a call
53     * to the static method <code>Socket.setSocketImplFactory</code>).  A   * to the static method <code>Socket.setSocketImplFactory</code>).  A
54     * subclass of <code>Socket</code> can also pass in a <code>SocketImpl</code>   * subclass of <code>Socket</code> can also pass in a <code>SocketImpl</code>
55     * to the <code>Socket(SocketImpl)</code> constructor to use an   * to the <code>Socket(SocketImpl)</code> constructor to use an
56     * implementation different from the system default without installing   * implementation different from the system default without installing
57     * a factory.   * a factory.
58     *   *
59     * @author Aaron M. Renn (arenn@urbanophile.com)   * @author Aaron M. Renn (arenn@urbanophile.com)
60     * @author Per Bothner <bothner@cygnus.com>   * @author Per Bothner <bothner@cygnus.com>
61     */   */
62  public abstract class SocketImpl implements SocketOptions  public abstract class SocketImpl implements SocketOptions
63  {  {
   
   
64    /**    /**
65     * The address of the remote end of the socket connection     * The address of the remote end of the socket connection
66     */     */
67    protected InetAddress address;    protected InetAddress address;
68    
69    /**    /**
70     * A FileDescriptor object representing this socket connection.       * A FileDescriptor object representing this socket connection.
71     */     */
72    protected FileDescriptor fd;    protected FileDescriptor fd;
73    
# Line 86  public abstract class SocketImpl impleme Line 84  public abstract class SocketImpl impleme
84    /**    /**
85     * Default, no-argument constructor for use by subclasses.     * Default, no-argument constructor for use by subclasses.
86     */     */
87    public SocketImpl ()    public SocketImpl()
88    {    {
89    }    }
90    
# Line 98  public abstract class SocketImpl impleme Line 96  public abstract class SocketImpl impleme
96     *     *
97     * @param stream true for a stream socket, false for a datagram socket     * @param stream true for a stream socket, false for a datagram socket
98     */     */
99    protected abstract void create (boolean stream) throws IOException;    protected abstract void create(boolean stream) throws IOException;
100    
101    /**    /**
102     * Connects to the remote hostname and port specified as arguments.     * Connects to the remote hostname and port specified as arguments.
# Line 108  public abstract class SocketImpl impleme Line 106  public abstract class SocketImpl impleme
106     *     *
107     * @exception IOException If an error occurs     * @exception IOException If an error occurs
108     */     */
109    protected abstract void connect (String host, int port) throws IOException;    protected abstract void connect(String host, int port) throws IOException;
110    
111    /**    /**
112     * Connects to the remote address and port specified as arguments.     * Connects to the remote address and port specified as arguments.
# Line 118  public abstract class SocketImpl impleme Line 116  public abstract class SocketImpl impleme
116     *     *
117     * @exception IOException If an error occurs     * @exception IOException If an error occurs
118     */     */
119    protected abstract void connect (InetAddress host, int port)    protected abstract void connect(InetAddress host, int port)
120      throws IOException;      throws IOException;
121    
122    /**    /**
# Line 133  public abstract class SocketImpl impleme Line 131  public abstract class SocketImpl impleme
131     *     *
132     * @exception IOException If an error occurs     * @exception IOException If an error occurs
133     */     */
134    protected abstract void bind (InetAddress host, int port) throws IOException;    protected abstract void bind(InetAddress host, int port) throws IOException;
135    
136    /**    /**
137     * Starts listening for connections on a socket. The backlog parameter     * Starts listening for connections on a socket. The backlog parameter
# Line 142  public abstract class SocketImpl impleme Line 140  public abstract class SocketImpl impleme
140     * number, additional connections will be refused.     * number, additional connections will be refused.
141     *     *
142     * @param backlog The length of the pending connection queue     * @param backlog The length of the pending connection queue
143     *     *
144     * @exception IOException If an error occurs     * @exception IOException If an error occurs
145     */     */
146    protected abstract void listen (int backlog) throws IOException;    protected abstract void listen(int backlog) throws IOException;
147    
148    /**    /**
149     * Accepts a connection on this socket.     * Accepts a connection on this socket.
# Line 154  public abstract class SocketImpl impleme Line 152  public abstract class SocketImpl impleme
152     *     *
153     * @exception IOException If an error occurs     * @exception IOException If an error occurs
154     */     */
155    protected abstract void accept (SocketImpl s) throws IOException;    protected abstract void accept(SocketImpl s) throws IOException;
156    
157    /**    /**
158     * Returns an <code>InputStream</code> object for reading from this socket.     * Returns an <code>InputStream</code> object for reading from this socket.
# Line 167  public abstract class SocketImpl impleme Line 165  public abstract class SocketImpl impleme
165    
166    /**    /**
167     * Returns an <code>OutputStream</code> object for writing to this socket     * Returns an <code>OutputStream</code> object for writing to this socket
168     *     *
169     * @return An <code>OutputStream</code> for writing to this socket.     * @return An <code>OutputStream</code> for writing to this socket.
170     *     *
171     * @exception IOException If an error occurs.     * @exception IOException If an error occurs.
# Line 182  public abstract class SocketImpl impleme Line 180  public abstract class SocketImpl impleme
180     *     *
181     * @exception IOException If an error occurs     * @exception IOException If an error occurs
182     */     */
183    protected abstract int available () throws IOException;    protected abstract int available() throws IOException;
184    
185    /**    /**
186     * Closes the socket.  This will normally cause any resources, such as the     * Closes the socket.  This will normally cause any resources, such as the
# Line 193  public abstract class SocketImpl impleme Line 191  public abstract class SocketImpl impleme
191     *     *
192     * @exception IOException If an error occurs     * @exception IOException If an error occurs
193     */     */
194    protected abstract void close () throws IOException;    protected abstract void close() throws IOException;
195    
196    /**    /**
197     * Returns the FileDescriptor objects for this socket.     * Returns the FileDescriptor objects for this socket.
198     *     *
199     * @return A FileDescriptor for this socket.     * @return A FileDescriptor for this socket.
200     */     */
201    protected FileDescriptor getFileDescriptor () { return fd; }    protected FileDescriptor getFileDescriptor() { return fd; }
202    
203    /**    /**
204     * Returns the remote address this socket is connected to     * Returns the remote address this socket is connected to
205     *     *
206     * @return The remote address     * @return The remote address
207     */     */
208    protected InetAddress getInetAddress () { return address; }    protected InetAddress getInetAddress() { return address; }
209    
210    /**    /**
211     * Returns the remote port this socket is connected to     * Returns the remote port this socket is connected to
212     *     *
213     * @return The remote port     * @return The remote port
214     */     */
215    protected int getPort () { return port; }    protected int getPort() { return port; }
216    
217    /**    /**
218     * Returns the local port this socket is bound to     * Returns the local port this socket is bound to
219     *     *
220     * @return The local port     * @return The local port
221     */     */
222    protected int getLocalPort () { return localport; }    protected int getLocalPort() { return localport; }
223    
224    /**    /**
225     * Returns a <code>String</code> representing the remote host and port of this     * Returns a <code>String</code> representing the remote host and port of
226     * socket.     * this socket.
227     *     *
228     * @return A <code>String</code> for this socket.     * @return A <code>String</code> for this socket.
229     */     */
230    public String toString ()    public String toString()
231    {    {
232      return "[addr=" + address.toString() + ",port=" + Integer.toString(port) +      return "[addr=" + address.toString() + ",port=" + Integer.toString(port)
233        ",localport=" + Integer.toString(localport) + "]";        + ",localport=" + Integer.toString(localport) + "]";
234    }    }
235  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26