TransmitFileOptions 열거형

정의

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

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

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

필드

Disconnect 1

전송을 위해 모든 파일 데이터를 큐에 대기시킨 후 전송 수준에서 연결 끊기를 시작합니다. ReuseSocket과 함께 사용하면 이 플래그는 파일이 전송된 후에 해당 소켓의 연결을 끊고 다시 사용할 수 있는 상태로 되돌립니다.

ReuseSocket 2

요청이 완료되면 소켓 핸들을 다시 사용할 수 있습니다. 이 플래그는 Disconnect도 지정된 경우에만 유효합니다. Disconnect과 함께 사용하면 이 플래그는 파일이 전송된 후에 해당 소켓의 연결을 끊고 다시 사용할 수 있는 상태로 되돌립니다.

UseDefaultWorkerThread 0

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

UseKernelApc 32

작업자 스레드 대신 커널 APC(Asynchronous Procedure Call)를 사용하여 긴 파일 전송 요청을 처리합니다. 긴 요청은 파일 또는 캐시에서 두 번 이상 읽어야 하는 요청으로 정의됩니다. 따라서 이 요청은 파일 크기와 지정된 송신 패킷 길이에 따라 달라집니다.

UseSystemThread 16

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

WriteBehind 4

파일 전송 요청을 보류하지 않고 즉시 완료합니다. 이 플래그를 지정한 경우 파일이 성공적으로 전송되면 시스템에서 데이터를 받아들인 것이지만 원격 끝점에서 데이터를 승인했는지 여부는 보장할 수 없습니다. 이 플래그는 DisconnectReuseSocket 플래그와 함께 사용하지 마십시오.

예제

다음 예제에서는 호출에서 사용 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 = gcnew IPEndPoint( ipAddr,11000 );

// Create a TCP socket.
Socket^ client = gcnew 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 );
array<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 );
array<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();
// 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 하는 것입니다.

적용 대상