> For the complete documentation index, see [llms.txt](https://trialkey.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trialkey.gitbook.io/docs/api-reference/methods/transmitfilebyname.md).

# TransmitFileByName

## Description

Transmits the specified file in high performance mode by sending the file directly from the file cache.

{% hint style="info" %}
**Good to know:** If you are creating a server that will transfer large files, this method can help send a file very efficiently with minimal coding.
{% endhint %}

## Remarks

This method provides the highest available level of efficiency for transferring files. The return value from this method is a handle to the file.

| Param               | Description                                                                                                                                                                                   |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SocketHandle        | Socket to send on                                                                                                                                                                             |
| FileToSend          | File to send                                                                                                                                                                                  |
| ErrCode             | Error code if unable to open file or the API fails, SocketQ will close the file handle regardless of the AutoCloseFile variable                                                               |
| AutoCloseFile       | Indicates whether SocketQ should automatically close the file after the transfer. The default is true. If this flag is set to false, it is the applications responsibility to close the file. |
| NumberOfBytesToSend | Indicates the number of bytes from the file to transmit, by default this method transfers the entire file                                                                                     |
| SendBufferSize      | Indicates the buffer size of each send operation in bytes                                                                                                                                     |
| FileBytePosOffset   | Indicates that the file transfer should start from this position in file                                                                                                                      |
| Flags               | As listed below                                                                                                                                                                               |

<table><thead><tr><th width="270">Flag</th><th>Description</th></tr></thead><tbody><tr><td>SSQ_TF_USE_DEFAULT_WORKER</td><td>Uses the systems default thread for sending</td></tr><tr><td>SSQ_TF_USE_SYSTEM_THREAD</td><td>Uses system threads for sending</td></tr><tr><td>SSQ_TF_USE_KERNEL_APC</td><td>Use Kernel APC instead</td></tr><tr><td>SSQ_TF_USE_DISCONNECT</td><td>Disconnect socket after sending</td></tr></tbody></table>

## Prototype

LONG CSockQ::TransmitFileByName(long SocketHandle, CHAR\* FileToSend, long \*ErrCode, BOOL AutoCloseFile, long NumberOfBytesToSend, long SendBufferSize, long FileBytePosOffset, INT Flags)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trialkey.gitbook.io/docs/api-reference/methods/transmitfilebyname.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
