LingerOption.LingerTime 속성

정의

데이터가 전송 대기 상태인 경우 Close() 메서드를 호출한 후 연결 상태를 유지할 시간을 가져오거나 설정합니다.

public:
 property int LingerTime { int get(); void set(int value); };
public int LingerTime { get; set; }
member this.LingerTime : int with get, set
Public Property LingerTime As Integer

속성 값

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.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.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

설명

닫힌 Socket 시간이 초과되기 전에 전송되지 않은 데이터를 전송하려고 시도하는 기간을 확인하려면 이 값을 사용합니다. 이 값을 원하는 제한 시간(초)으로 설정할 수도 있습니다.

속성이 Enabledtrue이고 0으로 설정 LingerTime 하면 은 Socket 나가는 네트워크 버퍼에 보낼 보류 중인 데이터를 모두 삭제합니다. 이 값을 변경하는 경우 변경된 LingerOption instance 메서드에 SetSocketOption 전달하거나 또는 LingerState 속성을 설정 LingerState 해야 합니다.

다음 표에서는 속성 및 속성에 저장된 속성의 Enabled 가능한 값에 LingerTime 대한 동작을 LingerState 설명합니다.

enable seconds 동작
false (사용 안 함), 기본값 시간 제한은 적용할 수 없습니다(기본값). 기본 IP 프로토콜 제한 시간이 만료될 때까지 연결 지향 소켓(예: TCP)에 대해 보류 중인 데이터를 보내려고 시도합니다.
true (사용) 0이 아닌 시간 제한 지정된 제한 시간이 만료될 때까지 보류 중인 데이터를 보내려고 시도하고 시도가 실패하면 Winsock이 연결을 다시 설정합니다.
true (사용) 시간 제한이 0입니다. 보류 중인 데이터를 모두 삭제합니다. 예를 들어 TCP(연결 지향 소켓)의 경우 Winsock은 연결을 다시 설정합니다.

IP 스택은 연결 왕복 시간에 따라 사용할 기본 IP 프로토콜 제한 시간을 계산합니다. 대부분의 경우에서 시간 제한이 스택에 의해 계산 애플리케이션에 의해 정의 된 보다 상대적입니다. 속성이 설정되지 않은 경우 소켓의 LingerState 기본 동작입니다.

속성에 LingerTimeLingerState 저장된 속성이 기본 IP 프로토콜 제한 시간보다 크게 설정되면 기본 IP 프로토콜 제한 시간이 계속 적용되고 재정의됩니다.

적용 대상