TransmitFileOptions 열거형

정의

TransmitFileOptions 열거형은 파일 전송 요청에 사용되는 값을 정의합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class TransmitFileOptions
[System.Flags]
public enum TransmitFileOptions
[<System.Flags>]
type TransmitFileOptions = 
Public Enum TransmitFileOptions
상속
TransmitFileOptions
특성

필드

Name Description
UseDefaultWorkerThread 0

기본 스레드를 사용하여 긴 파일 전송 요청을 처리합니다.

Disconnect 1

전송을 위해 모든 파일 데이터가 큐에 대기된 후 전송 수준 연결 끊기를 시작합니다. 이러한 플래그와 함께 ReuseSocket사용하면 파일이 전송된 후 소켓을 연결이 끊긴 재사용 가능한 상태로 반환합니다.

ReuseSocket 2

요청이 완료되면 소켓 핸들을 다시 사용할 수 있습니다. 이 플래그는 지정된 경우에만 Disconnect 유효합니다. 이러한 플래그와 함께 Disconnect사용하면 파일이 전송된 후 소켓을 연결이 끊긴 재사용 가능한 상태로 반환합니다.

WriteBehind 4

보류하지 않고 즉시 파일 전송 요청을 완료합니다. 이 플래그를 지정하고 파일 전송에 성공하면 시스템에서 데이터를 수락했지만 원격 엔드에서 반드시 승인하지는 않습니다. 플래그와 Disconnect 함께 이 플래그를 ReuseSocket 사용하지 마세요.

UseSystemThread 16

시스템 스레드를 사용하여 긴 파일 전송 요청을 처리합니다.

UseKernelApc 32

작업자 스레드 대신 커널 APC(비동기 프로시저 호출)를 사용하여 긴 파일 전송 요청을 처리합니다. 긴 요청은 파일 또는 캐시에서 둘 이상의 읽기가 필요한 요청으로 정의됩니다. 따라서 요청은 파일의 크기와 송신 패킷의 지정된 길이에 따라 달라집니다.

예제

다음 예제에서는 호출에서 사용 TransmitFileOptions 하는 방법을 보여 줍니다 Socket.SendFile. "test.txt" 파일은 로컬 컴퓨터의 루트 디렉터리에 있습니다. 이 예제에서는 데이터의 사전 버퍼 및 포스트 버퍼가 만들어지고 파일을 사용하여 원격 호스트로 전송됩니다. 시스템의 기본 스레드 UseDefaultWorkerThread 를 사용하려면 지정됩니다.

// Establish the local endpoint for the socket.
IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());
IPAddress  ipAddr = ipHost.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11000);

// Create a TCP socket.
Socket client = new Socket(AddressFamily.InterNetwork,
        SocketType.Stream, ProtocolType.Tcp);

// Connect the socket to the remote endpoint.
client.Connect(ipEndPoint);

// Send file fileName to the remote host with preBuffer and postBuffer data.
// There is a text file test.txt located in the root directory.
string fileName = "C:\\test.txt";

// Create the preBuffer data.
string string1 = String.Format("This is text data that precedes the file.{0}", Environment.NewLine);
byte[] preBuf = Encoding.ASCII.GetBytes(string1);

// Create the postBuffer data.
string string2 = String.Format("This is text data that will follow the file.{0}", Environment.NewLine);
byte[] postBuf = Encoding.ASCII.GetBytes(string2);

//Send file fileName with buffers and default flags to the remote device.
Console.WriteLine("Sending {0} with buffers to the host.{1}", fileName, Environment.NewLine);
client.SendFile(fileName, preBuf, postBuf, TransmitFileOptions.UseDefaultWorkerThread);

// Release the socket.
client.Shutdown(SocketShutdown.Both);
client.Close();

설명

메모

파일이 전송된 후 플래그 Disconnect 를 지정하고 ReuseSocket 소켓을 연결이 끊긴 재사용 가능한 상태로 반환합니다. 서비스 공급자가 파일 전송이 완료되기 전에 소켓과 연결된 서비스 품질을 즉시 삭제할 수 있으므로 QOS(서비스 품질)가 요청된 소켓에서 이러한 플래그를 사용하면 안 됩니다. QOS 사용 소켓의 가장 좋은 방법은 이러한 플래그에 의존하지 않고 파일 전송이 완료되면 호출 Socket.Close 하는 것입니다.

적용 대상