NetworkStream.ReadTimeout プロパティ
アセンブリ: System (system.dll 内)

Dim instance As NetworkStream Dim value As Integer value = instance.ReadTimeout instance.ReadTimeout = value
/** @property */ public int get_ReadTimeout () /** @property */ public void set_ReadTimeout (int value)
public override function get ReadTimeout () : int public override function set ReadTimeout (value : int)
読み取り操作が失敗するまでの経過時間 (ミリ秒単位) を指定する Int32。既定値は Infinite で、読み取り操作がタイムアウトしないことを示します。


このプロパティで指定した時間内に読み取り操作が完了しない場合、読み取り操作は IOException をスローします。
![]() |
---|
このプロパティは、Read メソッドの呼び出しで実行される同期読み取りだけに適用されます。このプロパティは、BeginRead メソッドの呼び出しで実行される非同期読み取りには適用されません。 |

ネットワーク ストリームの読み取りタイムアウトを 10 ミリ秒に設定するコード例を次に示します。
import System.*; import System.Text.*; import System.Net.*; import System.Net.Sockets.*; public class TCPClientExample { public static void main(String[] args) { // Create a client that will connect to a // server listening on the contoso1 computer // at port 11000. TcpClient tcpClient = new TcpClient(); tcpClient.Connect("contosoServer", 11000); // Get the stream used to read the message sent by the server. NetworkStream networkStream = tcpClient.GetStream(); // Set a 10 millisecond timeout for reading. networkStream.set_ReadTimeout(10); // Read the server message into a byte buffer. ubyte bytes[] = new ubyte[1024]; networkStream.Read(bytes, 0, 1024); //Convert the server's message into a string and display it. String data = Encoding.get_UTF8().GetString(bytes); Console.WriteLine("Server sent message: {0}", data); tcpClient.Close(); } //main } //TCPClientExample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からNetworkStream.ReadTimeout プロパティを検索する場合は、下記のリンクをクリックしてください。

- NetworkStream.ReadTimeout プロパティのページへのリンク