Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (22 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/java/net/ServerSocket.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    3939
    4040import java.io.IOException;
     41
     42
    4143
    4244/* Written using on-line Java Platform 1.2 API Specification.
     
    5052 * server sockets are ready to communicate with one another utilizing
    5153 * whatever application layer protocol they desire.
    52  * <p>
     54 *
    5355 * As with the <code>Socket</code> class, most instance methods of this class
    5456 * simply redirect their calls to an implementation class.
     
    5961public class ServerSocket
    6062{
    61 
    62   // Class Variables
    63 
    6463  /**
    6564   * This is the user defined SocketImplFactory, if one is supplied
    6665   */
    6766  private static SocketImplFactory factory;
    68 
    69   // Instance Variables
    7067
    7168  /**
     
    7673
    7774  /**
    78    * Private constructor that simply sets the implementation.
    79    */
    80   private ServerSocket()
     75   * ServerSocketChannel of this ServerSocket. This channel only exists
     76   * when the socket is created by ServerSocketChannel.open().
     77   */
     78  private ServerSocketChannel ch;
     79
     80  private boolean closed = false;
     81 
     82  /**
     83   * Constructor that simply sets the implementation.
     84   *
     85   * @exception IOException If an error occurs
     86   *
     87   * @specnote This constructor is public since JDK 1.4
     88   */
     89  public ServerSocket() throws IOException
    8190  {
    8291    if (factory != null)
     
    8493    else
    8594      impl = new PlainSocketImpl();
     95
     96
    8697  }
    8798
     
    94105   *
    95106   * @exception IOException If an error occurs
     107
     108
    96109   */
    97110  public ServerSocket (int port)
    98     throws java.io.IOException
     111    throws IOException
    99112  {
    100113    this(port, 50);
     
    111124   *
    112125   * @exception IOException If an error occurs
     126
     127
    113128   */
    114129  public ServerSocket (int port, int backlog)
    115     throws java.io.IOException
     130    throws IOException
    116131  {
    117132    this(port, backlog, null);
     
    130145   *
    131146   * @exception IOException If an error occurs
     147
     148
     149
     150
    132151   */
    133152  public ServerSocket (int port, int backlog, InetAddress bindAddr)
    134     throws java.io.IOException
     153    throws IOException
    135154  {
    136155    this();
     156
    137157    if (impl == null)
    138158      throw new IOException("Cannot initialize Socket implementation");
     
    151171
    152172  /**
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
    153225   * This method returns the local address to which this socket is bound
    154226   *
     
    157229  public InetAddress getInetAddress()
    158230  {
    159     return impl.getInetAddress();
     231    try
     232      {
     233        return (InetAddress) impl.getOption (SocketOptions.SO_BINDADDR);
     234      }
     235    catch (SocketException e)
     236      {
     237        return null;
     238      }
    160239  }
    161240
     
    168247  {
    169248    return impl.getLocalPort();
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
    170264  }
    171265
     
    176270   *
    177271   * @exception IOException If an error occurs
    178    */
    179   public Socket accept ()  throws IOException
    180   {
     272   * @exception SecurityException If a security manager exists and its
     273   * checkListen method doesn't allow the operation
     274   * @exception IllegalBlockingModeException If this socket has an associated
     275   * channel, and the channel is in non-blocking mode
     276   * @exception SocketTimeoutException If a timeout was previously set with
     277   * setSoTimeout and the timeout has been reached
     278   */
     279  public Socket accept () throws IOException
     280  {
     281    if (impl == null)
     282      throw new IOException ("Cannot initialize Socket implementation");
     283
     284    SecurityManager sm = System.getSecurityManager ();
     285    if (sm != null)
     286      sm.checkListen (impl.getLocalPort ());
     287
    181288    Socket s = new Socket();
    182289    implAccept (s);
     
    193300   *
    194301   * @exception IOException If an error occurs
    195    */
    196   protected final void implAccept (Socket s)  throws IOException
    197   {
     302   * @exception IllegalBlockingModeException If this socket has an associated
     303   * channel, and the channel is in non-blocking mode
     304   *
     305   * @since 1.1
     306   */
     307  protected final void implAccept (Socket s)
     308    throws IOException
     309  {
     310    if (ch != null && !ch.isBlocking())
     311      throw new IllegalBlockingModeException();
     312           
    198313    impl.accept(s.impl);
    199314  }
     
    206321  public void close () throws IOException
    207322  {
    208     impl.close();
     323    if (impl != null)
     324      impl.close ();
     325
     326    if (ch != null)
     327      ch.close ();
     328   
     329    closed = true;
     330  }
     331
     332  /**
     333   * Returns the unique ServerSocketChannel object
     334   * associated with this socket, if any.
     335   *
     336   * The socket only has a ServerSocketChannel if its created
     337   * by ServerSocketChannel.open.
     338   *
     339   * @since 1.4
     340   */
     341  public ServerSocketChannel getChannel()
     342  {
     343    return ch;
     344  }
     345
     346  /**
     347   * Returns true then the socket is bound, otherwise false
     348   *
     349   * @since 1.4
     350   */
     351  public boolean isBound()
     352  {
     353    try
     354      {
     355        Object bindaddr = impl.getOption (SocketOptions.SO_BINDADDR);
     356      }
     357    catch (SocketException e)
     358      {
     359        return false;
     360      }
     361   
     362    return true;
     363  }
     364
     365  /**
     366   * Returns true if the socket is closed, otherwise false
     367   *
     368   * @since 1.4
     369   */
     370  public boolean isClosed()
     371  {
     372    return closed;
    209373  }
    210374
     
    217381   * @param timeout The new SO_TIMEOUT value
    218382   *
    219    * @exception IOException If an error occurs
     383   * @exception SocketException If an error occurs
     384   *
     385   * @since 1.1
    220386   */
    221387  public void setSoTimeout (int timeout) throws SocketException
     
    236402   *
    237403   * @exception IOException If an error occurs
     404
     405
    238406   */
    239407  public int getSoTimeout () throws IOException
     
    248416
    249417  /**
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
    250504   * Returns the value of this socket as a <code>String</code>.
    251505   *
     
    254508  public String toString ()
    255509  {
    256     return "ServerSocket " + impl.toString();
     510    return "ServerSocket" + impl.toString();
    257511  }
    258512
Note: See TracChangeset for help on using the changeset viewer.