From cba657bc44568834f63573241d271bb842049e18 Mon Sep 17 00:00:00 2001 From: Ano-sys Date: Sun, 22 Feb 2026 22:18:25 +0100 Subject: [PATCH] Add readme --- .gitignore | 5 +++ README.md | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..add57be --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..575b92d --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# DirectoryScanReceiver + +`DirectoryScanReceiver` is a small TCP server that receives file data over a simple delimiter-based protocol and writes files into an `output` directory. + +It is the receiver counterpart to [`DirectoryScanSender`](../DirectoryScanSender), and both projects can work together out of the box with the current default settings. + +## Companion Project + +- Sender counterpart: [`DirectoryScanSender`](../DirectoryScanSender) +- Shared default TCP port: `7156` + +## Shared Protocol + +Both projects use the same message format: + +```text +||\r\n\r\n +``` + +- `path`: file path string sent by the sender +- `length`: declared payload length +- `content`: payload content + +Multiple messages can be sent over the same TCP connection, each terminated by `\r\n\r\n`. + +## Features + +- Listens for TCP connections on port `7156` +- Accepts multiple file messages over a connection +- Writes files to an `output` directory next to the executable +- Creates subdirectories when needed +- Skips existing files (no overwrite) +- Prevents writing outside the `output` directory + +## Runtime Behavior + +- The server waits for incoming TCP connections. +- Each valid message is parsed and written as one file. +- Empty or invalid messages are ignored. +- The `output` directory is cleared once when the application starts. + +Console output includes connection events, received payload sizes, and written file paths. + +## Requirements + +- .NET SDK with support for `net10.0` + +## Build and Run + +From the repository root: + +```bash +dotnet build +dotnet run --project DirectoryScanReceiver +``` + +The server prints messages such as: + +- `Started Server!` +- `Waiting for data!` + +## Test Message Example + +Using `nc` (netcat): + +```bash +printf 'hello.txt|5|hello\r\n\r\n' | nc 127.0.0.1 7156 +``` + +This writes `hello.txt` into the receiver's `output` directory. + +Subdirectories are also supported: + +```bash +printf 'subdir/note.txt|11|hello world\r\n\r\n' | nc 127.0.0.1 7156 +``` + +## Notes + +- The protocol is simple and delimiter-based. +- The receiver is intended to be used with [`DirectoryScanSender`](../DirectoryScanSender) or another sender that follows the same message format. +- The current defaults match the local `DirectoryScanSender` project (`localhost:7156`). +- The service uses plain TCP and does not include authentication or encryption. + +## License and Disclaimer + +This project may be used, copied, modified, and shared freely. + +It is provided `as is`, without warranty of any kind. The author is not liable for any damages or losses resulting from its use.