NetworkStream.Write メソッド
アセンブリ: System (system.dll 内)

Dim instance As NetworkStream Dim buffer As Byte() Dim offset As Integer Dim size As Integer instance.Write(buffer, offset, size)


Write メソッドは、指定した offset から始まり、buffer の内容の size バイトをネットワークに送信します。Write メソッドは、要求されたバイト数が送信されるか、SocketException がスローされるまでブロックします。SocketException が発生した場合は、SocketException.ErrorCode プロパティを使用して特定のエラー コードを取得してください。エラーの詳細については、MSDN で Windows Socket Version 2 API のエラー コードのドキュメントを参照してください。
![]() |
---|
CanWrite プロパティにアクセスして、NetworkStream が書き込み可能かどうかを確認します。書き込むことができない NetworkStream に書き込もうとすると、IOException が発生します。IOException が発生した場合は、InnerException プロパティをチェックして、この原因が SocketException かどうかを確認してください。 |

NetworkStream が書き込み可能かどうかを確認するコード例を次に示します。書き込み可能の場合、Write は小さなメッセージを書くときに使用します。
' Check to see if this NetworkStream is writable. If myNetworkStream.CanWrite Then Dim myWriteBuffer As Byte() = Encoding.ASCII.GetBytes("Are you receiving this message?") myNetworkStream.Write(myWriteBuffer, 0, myWriteBuffer.Length) Else Console.WriteLine("Sorry. You cannot write to this NetworkStream.") End If
// Check to see if this NetworkStream is writable. if (myNetworkStream.CanWrite){ byte[] myWriteBuffer = Encoding.ASCII.GetBytes("Are you receiving this message?"); myNetworkStream.Write(myWriteBuffer, 0, myWriteBuffer.Length); } else{ Console.WriteLine("Sorry. You cannot write to this NetworkStream."); }
// Check to see if this NetworkStream is writable. if (myNetworkStream.get_CanWrite()) { ubyte myWriteBuffer[] = Encoding.get_ASCII(). GetBytes("Are you receiving this message?"); myNetworkStream.Write(myWriteBuffer, 0, myWriteBuffer.get_Length()); } else { Console.WriteLine("Sorry. You cannot write to this " + "NetworkStream."); }

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.Write メソッドを検索する場合は、下記のリンクをクリックしてください。

- NetworkStream.Write メソッドのページへのリンク