public abstract class SocketImpl extends Object implements SocketOptions
SocketImplは、実際にソケットを実装するすべてのクラスに共通のスーパー・クラスです。 これはクライアント・ソケット、サーバー・ソケットの両方の作成に使用されます。
「プレーンな」ソケットは、各メソッドを記述のとおりに実装します。ファイアウォールやプロキシは使用しません。
| 修飾子と型 | フィールド | 説明 |
|---|---|---|
protected InetAddress |
address |
このソケットのリモート側のIPアドレスです。
|
protected FileDescriptor |
fd |
このソケットのファイル記述子オブジェクトです。
|
protected int |
localport |
このソケットの接続先のローカル・ポート番号です。
|
protected int |
port |
このソケットの接続先のリモート・ホスト上にあるポート番号です。
|
IP_MULTICAST_IF, IP_MULTICAST_IF2, IP_MULTICAST_LOOP, IP_TOS, SO_BINDADDR, SO_BROADCAST, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE, 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) |
指定されたローカルのIPアドレスとポート番号にこのソケットをバインドします。
|
protected abstract void |
close() |
このソケットを閉じます。
|
protected abstract void |
connect(InetAddress address, int port) |
指定されたホスト上の指定されたポートにこのソケットを接続します。
|
protected abstract void |
connect(SocketAddress address, int timeout) |
指定されたホスト上の指定されたポートにこのソケットを接続します。
|
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 abstract void |
sendUrgentData(int data) |
このソケット上で1バイトの緊急データを送信します。
|
protected void |
setPerformancePreferences(int connectionTime, int latency, int bandwidth) |
このソケットのパフォーマンス設定を行います。
|
protected void |
shutdownInput() |
このソケットの入力ストリームを「ストリームの終わり」に設定します。
|
protected void |
shutdownOutput() |
このソケットの出力ストリームを無効にします。
|
protected boolean |
supportsUrgentData() |
このSocketImplが緊急データの送信をサポートするかどうかを返します。
|
String |
toString() |
このソケットのアドレスとポートを
Stringとして返します。 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetOption, setOptionprotected FileDescriptor fd
protected InetAddress address
protected int port
protected int localport
protected abstract void create(boolean stream)
throws IOException
stream - trueの場合はストリーム・ソケットを作成し、それ以外の場合はデータグラム・ソケットを作成します。IOException−ソケットの作成中に入出力エラーが発生した場合。protected abstract void connect(String host, int port) throws IOException
host−リモート・ホスト名。port - ポート番号。IOException−リモート・ホストへの接続時に入出力エラーが発生した場合。protected abstract void connect(InetAddress address, int port) throws IOException
address−リモート・ホストのIPアドレス。port - ポート番号。IOException - 接続の試行中に入出力エラーが発生した場合。protected abstract void connect(SocketAddress address, int timeout) throws IOException
address−リモート・ホストのソケット・アドレス。timeout−タイム・アウト値(ミリ秒)。タイム・アウトなしの場合は0。IOException - 接続の試行中に入出力エラーが発生した場合。protected abstract void bind(InetAddress host, int port) throws IOException
host−ローカル・インタフェースに属するIPアドレス。port - ポート番号。IOException−このソケットをバインドするときに入出力エラーが発生した場合。protected abstract void listen(int backlog)
throws IOException
count引数に設定します。 キューが埋まっているときに接続要求があると、接続は拒否されます。 backlog−キューの最大長。IOException−キューの生成中に入出力エラーが発生した場合。protected abstract void accept(SocketImpl s) throws IOException
s−受け入れる接続。IOException−接続の受け入れ中に入出力エラーが発生した場合。protected abstract InputStream getInputStream() throws IOException
IOException−入力ストリームの作成中に入出力エラーが発生した場合。protected abstract OutputStream getOutputStream() throws IOException
IOException−出力ストリームの作成中に入出力エラーが発生した場合。protected abstract int available()
throws IOException
IOException−使用可能なバイト数の決定時に入出力エラーが発生した場合。protected abstract void close()
throws IOException
IOException - このソケットを閉じるときに入出力エラーが発生した場合。protected void shutdownInput()
throws IOException
availableメソッドは0を返し、readメソッドは-1 (ストリームの終わり)を返します。 IOException - このソケットを停止するときに入出力エラーが発生した場合。Socket.shutdownOutput(), Socket.close(), Socket.setSoLinger(boolean, int)protected void shutdownOutput()
throws IOException
IOException - このソケットを停止するときに入出力エラーが発生した場合。Socket.shutdownInput(), Socket.close(), Socket.setSoLinger(boolean, int)protected FileDescriptor getFileDescriptor()
fdフィールドの値を返します。fdフィールドの値。fdprotected InetAddress getInetAddress()
addressフィールドの値を返します。addressフィールドの値。addressprotected int getPort()
portフィールドの値を返します。portフィールドの値。portprotected boolean supportsUrgentData()
addressprotected abstract void sendUrgentData(int data)
throws IOException
data - 送信するデータのバイトIOException - データ送信時にエラーが発生した場合。protected int getLocalPort()
localportフィールドの値を返します。localportフィールドの値。localportpublic String toString()
Stringとして返します。protected void setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
ソケットはデフォルトで、TCP/IPプロトコルを使用します。 実装によっては、TCP/IPとは異なるパフォーマンス特性を持つ代替プロトコルを提供することもあります。 アプリケーションは、このメソッドを使用することで、実装で利用可能なプロトコルの選択時に、これらのかね合いの取り方を示す独自の設定を表現できます。
パフォーマンス設定は、接続時間の短さ、応答時間の速さ、および帯域幅の広さの相対的な重要度を示す3つの整数値によって記述されます。 これらの整数の絶対値は重要ではありません。ある特定のプロトコルを選択するために、これらの値が単純に比較されますが、その際、値が大きければより強い設定を示します。 負の値は正の値よりも低い優先順位を表します。 たとえば、アプリケーションが応答時間の速さや帯域幅の広さよりも接続時間の短さを優先する場合には、値(1, 0, 0)を指定してこのメソッドを呼び出すことができます。 アプリケーションが応答時間の速さよりも帯域幅の広さを優先し、接続時間の短さよりも応答時間の速さを優先する場合には、値(0, 1, 2)を指定してこのメソッドを呼び出すことができます。 このメソッドは、サブクラス内でオーバーライドされていないかぎり、デフォルトでは何も行いません。
connectionTime - 接続時間の短さの相対的な重要度を表すintlatency - 応答時間の速さの相対的な重要度を表すintbandwidth - 帯域幅の広さの相対的な重要度を表すint バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。