Sportronics.SendVideoOverTcpLib
2.0.0
The wrong project was built and uploaded as this package!. Incorrect Id for it.
See the version list below for details.
dotnet add package Sportronics.SendVideoOverTcpLib --version 2.0.0
NuGet\Install-Package Sportronics.SendVideoOverTcpLib -Version 2.0.0
<PackageReference Include="Sportronics.SendVideoOverTcpLib" Version="2.0.0" />
<PackageVersion Include="Sportronics.SendVideoOverTcpLib" Version="2.0.0" />
<PackageReference Include="Sportronics.SendVideoOverTcpLib" />
paket add Sportronics.SendVideoOverTcpLib --version 2.0.0
#r "nuget: Sportronics.SendVideoOverTcpLib, 2.0.0"
#:package Sportronics.SendVideoOverTcpLib@2.0.0
#addin nuget:?package=Sportronics.SendVideoOverTcpLib&version=2.0.0
#tool nuget:?package=Sportronics.SendVideoOverTcpLib&version=2.0.0
DownloadVideoOverTcpLib
A .NET library for receiving video files over TCP with checksum verification. This library provides a simple and reliable way to download video files from a sender over a TCP connection.
Features
- TCP-based file transfer with automatic connection handling
- Checksum verification using SHA-256
- A Json file with meta info is transferred first
- Containing the expected checksum and filename
- Also the Video TimeFrom mode, Video Start Time, and GunTime if relevant.
- A Json file with meta info is transferred first
- Progress reporting during download
- Cross-platform compatibility (.NET 9.0)
- Simple API for easy integration
Requirements
- .NET 9.0 or later
Installation
Add a reference to the DownloadVideoOverTcpLib project in your solution or install the NuGet package:
dotnet add package DownloadVideoOverTcpLib
Usage
Basic Usage
The simplest way to use the library is to call the Download
method:
using DownloadVideoOverTCPLib;
// Specify download folder and port
string downloadFolder = @"C:\temp\videos";
int port = 5000;
// Start listening and download the file
string fileName = GetVideo.Download(downloadFolder, port);
if (!string.IsNullOrEmpty(fileName))
{
Console.WriteLine($"File downloaded successfully: {fileName}");
}
else
{
Console.WriteLine("Download failed");
}
Console Application Example
Here's how to use the library in a console application with configuration support:
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using DownloadVideoOverTCPLib;
using Microsoft.Extensions.Configuration;
class Program
{
static void Main(string[] args)
{
// Load configuration from appsettings.json
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddCommandLine(args)
.Build();
// Get settings from configuration
string folder = config["AppSettings:Folder"] ?? @"C:\temp\videos";
int port = int.Parse(config["AppSettings:Port"] ?? "5000");
// Create folder if it doesn't exist
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
// Display local IP for connecting clients
string localIP = GetLocalIPAddress();
Console.WriteLine($"App is running at IP: {localIP}, Port: {port}");
Console.WriteLine($"Using folder: {folder}");
// Start download
var filepath = GetVideo.Download(folder, port);
Console.WriteLine($"File received: {filepath} in folder {folder}");
}
static string GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
return ip.ToString();
}
return "No network adapters with an IPv4 address in the system!";
}
}
Configuration File (appsettings.json)
{
"AppSettings": {
"Folder": "C:\\temp\\videos",
"Port": 5000
}
}
How It Works
- The library starts a TCP listener on the specified port
- When a client connects, it receives:
- The file name length (as an integer)
- The file name (as a UTF-8 string)
- The expected SHA-256 checksum (32 bytes)
- The file data
- The file is saved to the specified folder
- The actual checksum is calculated and compared with the expected checksum
- The result is reported to the console
Advanced Usage
Error Handling
The library includes built-in error handling, but you can add additional error handling in your application:
try
{
string fileName = GetVideo.Download(downloadFolder, port);
// Process the downloaded file
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
// Handle the error
}
License
This project is licensed under the Creative Commons CC0-1.0 Universal License - see the LICENSE file for details.
CC0-1.0 is a public domain dedication that allows you to freely use, modify, and distribute this code without any restrictions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0-windows7.0 is compatible. net10.0-windows was computed. |
-
net9.0-windows7.0
- Extended.Wpf.Toolkit (>= 4.7.25104.5739)
- VideoEnums.Windows (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Json Meta info file transferred before video incl. filename and checksum