SocketImpl.java 1.94 KB
Newer Older
Tom Tromey committed
1 2
// SocketImpl.java - Abstract socket implementation.

3
/* Copyright (C) 1999  Free Software Foundation
Tom Tromey committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

package java.net;
import java.io.*;

/**
  * @author Per Bothner <bothner@cygnus.com>
  * @date January 6, 1999.
  */

/** Written using on-line Java Platform 1.2 API Specification.
Warren Levy committed
20
  * Believed complete and correct.
Tom Tromey committed
21 22
  */

Warren Levy committed
23
public abstract class SocketImpl implements SocketOptions
Tom Tromey committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
{
  protected InetAddress address;

  protected FileDescriptor fd;

  protected int localport;

  protected int port;

  public SocketImpl ()
  {
  }

  protected abstract void create (boolean stream) throws IOException;

  protected abstract void connect (String host, int port) throws IOException;

  protected abstract void connect (InetAddress host, int port)
    throws IOException;

  protected abstract void bind (InetAddress host, int port) throws IOException;

  protected abstract void listen (int backlog) throws IOException;

  protected abstract void accept (SocketImpl s) throws IOException;

  protected abstract InputStream getInputStream() throws IOException;

  protected abstract OutputStream getOutputStream() throws IOException;

  protected abstract int available () throws IOException;

  protected abstract void close () throws IOException;

  protected FileDescriptor getFileDescriptor () { return fd; }

  protected InetAddress getInetAddress () { return address; }

  protected int getPort () { return port; }

  protected int getLocalPort () { return localport; }

Warren Levy committed
66 67 68 69 70
  public abstract Object getOption(int optID) throws SocketException;

  public abstract void setOption(int optID, Object value)
    throws SocketException;

Tom Tromey committed
71 72
  public String toString ()
  {
Warren Levy committed
73 74
    return "[addr=" + address.toString() + ",port=" + Integer.toString(port) +
      ",localport=" + Integer.toString(localport) + "]";
Tom Tromey committed
75 76
  }
}