Socket.SendBufferSize 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
의 송신 버퍼 Socket크기를 지정하는 값을 가져오거나 설정합니다.
public:
property int SendBufferSize { int get(); void set(int value); };
public int SendBufferSize { get; set; }
member this.SendBufferSize : int with get, set
Public Property SendBufferSize As Integer
속성 값
Int32 송신 버퍼의 크기(바이트)를 포함하는 형식입니다. 기본값은 운영 체제에 따라 달라집니다.
예외
소켓에 액세스하려고 할 때 오류가 발생했습니다.
Socket 닫혔습니다.
set 작업에 대해 지정된 값이 0보다 작습니다.
예제
다음 코드 예제에서는 속성의 사용을 보여 줍니다 SendBufferSize .
static void ConfigureTcpSocket(Socket tcpSocket)
{
// Don't allow another socket to bind to this port.
tcpSocket.ExclusiveAddressUse = true;
// The socket will linger for 10 seconds after
// Socket.Close is called.
tcpSocket.LingerState = new LingerOption (true, 10);
// Disable the Nagle Algorithm for this tcp socket.
tcpSocket.NoDelay = true;
// Set the receive buffer size to 8k
tcpSocket.ReceiveBufferSize = 8192;
// Set the timeout for synchronous receive methods to
// 1 second (1000 milliseconds.)
tcpSocket.ReceiveTimeout = 1000;
// Set the send buffer size to 8k.
tcpSocket.SendBufferSize = 8192;
// Set the timeout for synchronous send methods
// to 1 second (1000 milliseconds.)
tcpSocket.SendTimeout = 1000;
// Set the Time To Live (TTL) to 42 router hops.
tcpSocket.Ttl = 42;
Console.WriteLine("Tcp Socket configured:");
Console.WriteLine($" ExclusiveAddressUse {tcpSocket.ExclusiveAddressUse}");
Console.WriteLine($" LingerState {tcpSocket.LingerState.Enabled}, {tcpSocket.LingerState.LingerTime}");
Console.WriteLine($" NoDelay {tcpSocket.NoDelay}");
Console.WriteLine($" ReceiveBufferSize {tcpSocket.ReceiveBufferSize}");
Console.WriteLine($" ReceiveTimeout {tcpSocket.ReceiveTimeout}");
Console.WriteLine($" SendBufferSize {tcpSocket.SendBufferSize}");
Console.WriteLine($" SendTimeout {tcpSocket.SendTimeout}");
Console.WriteLine($" Ttl {tcpSocket.Ttl}");
Console.WriteLine($" IsBound {tcpSocket.IsBound}");
Console.WriteLine("");
}
설명
버퍼 크기가 클수록 연결 난이도 인식이 지연될 수 있습니다. 대용량 파일을 전송하거나 대역폭이 높고 대기 시간이 긴 연결(예: 위성 광대역 공급자)을 사용하는 경우 버퍼 크기를 늘리는 것이 좋습니다.