LingerOption.LingerTime プロパティ
アセンブリ: System (system.dll 内)
構文Dim instance As LingerOption Dim value As Integer value = instance.LingerTime instance.LingerTime = value
/** @property */ public int get_LingerTime () /** @property */ public void set_LingerTime (int value)
Socket.Close が呼び出された後、接続を維持する秒数。
解説閉じられた Socket がタイムアウト前に未送信のデータを転送しようとする時間を確認する場合は、この値を使用します。また、この値を希望するタイムアウト時間 (秒) に設定することもできます。Enabled プロパティが true の場合、LingerTime を 0 に設定すると、Socket は発信ネットワーク バッファに残っているデータがなくなるまでデータを送信しようとします。この値を変更する場合は、変更された LingerOption を SetSocketOption メソッドまたは LingerState メソッドに渡す必要があります。
使用例Console.WriteLine(("This application will timeout if Send does not return within " + Encoding.ASCII.GetString(s.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 4)))) ' blocks until send returns Dim i As Integer = s.Send(msg) ' blocks until read returns Dim bytes(1024) As Byte s.Receive(bytes) 'Display to the screen Console.WriteLine(Encoding.ASCII.GetString(bytes)) s.Shutdown(SocketShutdown.Both) Console.WriteLine(("If data remains to be sent, this application will stay open for " + CType(s.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger), LingerOption).LingerTime.ToString())) s.Close() End Sub 'SetSocketOptions
Console.WriteLine ("This application will timeout if Send
does not return within " + Encoding.ASCII.GetString (s.GetSocketOption
(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 4)));
// blocks until send returns
int i = s.Send (msg);
// blocks until read returns
byte[] bytes = new byte[1024];
s.Receive (bytes);
//Display to the screen
Console.WriteLine (Encoding.ASCII.GetString (bytes));
s.Shutdown (SocketShutdown.Both);
Console.WriteLine ("If data remains to be sent, this application
will stay open for " + ((LingerOption)s.GetSocketOption
(SocketOptionLevel.Socket, SocketOptionName.Linger)).LingerTime.ToString ());
s.Close ();
Console::Write( "This application will timeout if Send does not return within " ); Console::WriteLine( Encoding::ASCII->GetString( s->GetSocketOption( SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 4 ) ) ); // Blocks until send returns. int i = s->Send( msg ); // Blocks until read returns. array<Byte>^ bytes = gcnew array<Byte>(1024); s->Receive( bytes ); //Displays to the screen. Console::WriteLine( Encoding::ASCII->GetString( bytes ) ); s->Shutdown( SocketShutdown::Both ); Console::Write( "If data remains to be sent, this application will stay open for " ); Console::WriteLine( safe_cast<LingerOption^>(s->GetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Linger ))->LingerTime.ToString() ); s->Close();
Console.WriteLine("This application will timeout if Send
does not "
+ "return within " + Encoding.get_ASCII().GetString(s.
GetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 4)));
// blocks until send returns
int i = s.Send(msg);
// blocks until read returns
ubyte bytes[] = new ubyte[1024];
s.Receive(bytes);
//Display to the screen
Console.WriteLine(Encoding.get_ASCII().GetString(bytes));
s.Shutdown(SocketShutdown.Both);
Console.WriteLine("If data remains to be sent, this application
"
+ "will stay open for " + ((LingerOption)(s.
GetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Linger))).get_LingerTime());
s.Close();
} //SetSocketOptions
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- LingerOption.LingerTime プロパティのページへのリンク