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


NetworkStream の派生クラスは、このプロパティを使用して基になる Socket を取得します。NetworkStream が提供する以上のアクセスが必要な場合は、Socket プロパティが返した、基になる Socket を使用します。
![]() |
---|

基になる Socket を取得してアクティブな接続を確認するコード例を次に示します。
Public Class MyNetworkStream_Sub_Class Inherits NetworkStream Public Sub New(socket As Socket, ownsSocket As Boolean) MyBase.New(socket, ownsSocket) End Sub 'New ' Suppose you wanted a property for determining if Socket is connected. You can use ' the protected method 'Socket' to return underlying Socket. Public ReadOnly Property Connected() As Boolean Get Return Me.Socket.Connected End Get End Property ' You could also use public NetworkStream methods 'CanRead' and 'CanWrite'. Public ReadOnly Property CanCommunicate() As Boolean Get If Not Me.Readable Or Not Me.Writeable Then Return False Else Return True End If End Get End Property Public Shared Sub DoSomethingSignificant() End Sub 'DoSomethingSignificant ' Do something significant in here
using System; using System.Net; using System.Net.Sockets; public class MyNetworkStream_Sub_Class : NetworkStream { public MyNetworkStream_Sub_Class(Socket socket, bool ownsSocket) : base(socket, ownsSocket) { } // You can use the Socket method to examine the underlying Socket. public bool Connected { get { return this.Socket.Connected; } } public bool CanCommunicate { get { if (!this.Readable | !this.Writeable) { return false; } else { return true; } } }
import System.*; import System.Net.*; import System.Net.Sockets.*; public class MyNetworkStreamSubClass extends NetworkStream { public MyNetworkStreamSubClass(Socket socket, boolean ownsSocket) { super(socket, ownsSocket); } //MyNetworkStreamSubClass // You can use the Socket method to examine the underlying Socket. /** @property */ public boolean get_Connected() { return this.get_Socket().get_Connected(); } //get_Connected /** @property */ public boolean get_CanCommunicate() { if (!(this.get_Readable()) | !(this.get_Writeable())) { return false; } else { return true; } } //get_CanCommunicate

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.Socket プロパティを検索する場合は、下記のリンクをクリックしてください。

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