JavaTM 2 Platform
Std. Ed. v1.3

java.net
クラス SocketImpl

java.lang.Object
  |
  +--java.net.SocketImpl
すべての実装インタフェース:
SocketOptions

public abstract class SocketImpl
extends Object
implements SocketOptions

抽象クラス SocketImpl は、ソケットを実際に実装するすべてのクラスに共通のスーパークラスです。クライアントソケットとサーバソケットの両方を作成する際に使用されます。

「プレーンな」ソケットは、各メソッドを記述のとおりに実装します。ファイアウォールやプロキシは使用しません。

導入されたバージョン:
JDK1.0

フィールドの概要
protected  InetAddress address
          このソケットのリモート側の IP アドレスです。
protected  FileDescriptor fd
          このソケットのファイル記述子オブジェクトです。
protected  int localport
          このソケットの接続先のローカルポート番号です。
protected  int port
          このソケットの接続先のリモートホスト上にあるポート番号です。
 
インタフェース java.net.SocketOptions から継承したフィールド
IP_MULTICAST_IF, SO_BINDADDR, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY
 
コンストラクタの概要
SocketImpl()
           
 
メソッドの概要
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()
          このソケットの fd フィールド値を返します。
protected  InetAddress getInetAddress()
          このソケットの address フィールド値を返します。
protected abstract  InputStream getInputStream()
          このソケットの入力ストリームを返します。
protected  int getLocalPort()
          このソケットの localport フィールド値を返します。
protected abstract  OutputStream getOutputStream()
          このソケットの出力ストリームを返します。
protected  int getPort()
          このソケットの port フィールド値を返します。
protected abstract  void listen(int backlog)
          受信する接続 (接続要求) を入れるキューの最大長を、count 引数の値に設定します。
protected  void shutdownInput()
          このソケットの入力ストリームを「ストリームの最後」に配置します。
protected  void shutdownOutput()
          このソケットの出力ストリームを無効にします。
 String toString()
          このソケットのアドレスとポートを String として返します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
インタフェース java.net.SocketOptions から継承したメソッド
getOption, setOption
 

フィールドの詳細

fd

protected FileDescriptor fd
このソケットのファイル記述子オブジェクトです。

address

protected InetAddress address
このソケットのリモート側の IP アドレスです。

port

protected int port
このソケットの接続先のリモートホスト上にあるポート番号です。

localport

protected int localport
このソケットの接続先のローカルポート番号です。
コンストラクタの詳細

SocketImpl

public SocketImpl()
メソッドの詳細

create

protected abstract void create(boolean stream)
                        throws IOException
ストリームソケットまたはデータグラムソケットを作成します。
パラメータ:
stream - true を指定した場合はストリームソケットが作成され、そうでない場合はデータグラムソケットが作成される
例外:
IOException - ソケットの生成中に入出力エラーが発生した場合

connect

protected abstract void connect(String host,
                                int port)
                         throws IOException
指定されたホスト上の指定されたポートにこのソケットを接続します。
パラメータ:
host - リモートホスト名
port - ポート番号
例外:
IOException - リモートホストへの接続中に入出力エラーが発生した場合

connect

protected abstract void connect(InetAddress address,
                                int port)
                         throws IOException
指定されたホスト上の指定されたポートにこのソケットを接続します。
パラメータ:
address - リモートホストの IP アドレス
port - ポート番号
例外:
IOException - 接続の試行中に入出力エラーが発生した場合

bind

protected abstract void bind(InetAddress host,
                             int port)
                      throws IOException
指定されたホスト上の指定されたポート番号にこのソケットをバインドします。
パラメータ:
host - リモートホストの IP アドレス
port - ポート番号
例外:
IOException - このソケットをバインドするときに入出力エラーが発生した場合

listen

protected abstract void listen(int backlog)
                        throws IOException
受信する接続 (接続要求) を入れるキューの最大長を、count 引数の値に設定します。キューが埋まっているときに接続要求があると、接続は拒否されます。
パラメータ:
backlog - キューの最大長
例外:
IOException - キューの生成中に入出力エラーが発生した場合

accept

protected abstract void accept(SocketImpl s)
                        throws IOException
接続を受け入れます。
パラメータ:
s - 受け入れる接続
例外:
IOException - 接続の受け入れ中に入出力エラーが発生した場合

getInputStream

protected abstract InputStream getInputStream()
                                       throws IOException
このソケットの入力ストリームを返します。
戻り値:
このソケットからの入力を読み込むためのストリーム
例外:
IOException - 入力ストリームの作成中に入出力エラーが発生した場合

getOutputStream

protected abstract OutputStream getOutputStream()
                                         throws IOException
このソケットの出力ストリームを返します。
戻り値:
このソケットに書き込むための出力ストリーム
例外:
IOException - 出力ストリームの作成中に入出力エラーが発生した場合

available

protected abstract int available()
                          throws IOException
このソケットからブロックなしで読み込めるバイト数を返します。
戻り値:
このソケットからブロックなしで読み込めるバイト数
例外:
IOException - 利用できるバイト数の決定時に入出力エラーが発生した場合

close

protected abstract void close()
                       throws IOException
このソケットを閉じます。
例外:
IOException - このソケットを閉じるときに入出力エラーが発生した場合

shutdownInput

protected void shutdownInput()
                      throws IOException
このソケットの入力ストリームを「ストリームの最後」に配置します。このソケットに送信されたデータは確認され、そのまま破棄されます。 ソケットで shutdownInput() を呼び出したあとにソケットの入力ストリームから読み込むと、ストリームは EOF を返します。
例外:
IOException - このソケットを停止するときに入出力エラーが発生した場合
関連項目:
Socket.shutdownOutput(), Socket.close(), Socket.setSoLinger(boolean, int)

shutdownOutput

protected void shutdownOutput()
                       throws IOException
このソケットの出力ストリームを無効にします。TCP ソケットの場合、すでに書き込まれているデータが送信され、そのあとに TCP の通常の接続終了処理が続きます。 ソケットで shutdownOutput() を呼び出したあとにソケットの出力ストリームに書き込むと、ストリームは IOException をスローします。
例外:
IOException - このソケットを停止するときに入出力エラーが発生した場合
関連項目:
Socket.shutdownInput(), Socket.close(), Socket.setSoLinger(boolean, int)

getFileDescriptor

protected FileDescriptor getFileDescriptor()
このソケットの fd フィールド値を返します。
戻り値:
このソケットの fd フィールド値
関連項目:
fd

getInetAddress

protected InetAddress getInetAddress()
このソケットの address フィールド値を返します。
戻り値:
このソケットの address フィールド値
関連項目:
address

getPort

protected int getPort()
このソケットの port フィールド値を返します。
戻り値:
このソケットの port フィールド値
関連項目:
port

getLocalPort

protected int getLocalPort()
このソケットの localport フィールド値を返します。
戻り値:
このソケットの localport フィールド値
関連項目:
localport

toString

public String toString()
このソケットのアドレスとポートを String として返します。
オーバーライド:
クラス Object 内の toString
戻り値:
このソケットの文字列表現

JavaTM 2 Platform
Std. Ed. v1.3

バグや機能要求の報告
さらに詳しい API リファレンスおよび開発者ドキュメントについては、 Java 2 SDK SE Developer Documentation を参照してください。このドキュメントには、概念、用語の定義、回避策、 実用的なコード例など、開発者を対象にした詳細な解説が掲載されています。

Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.