HiSocket 2.7.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package HiSocket --version 2.7.3
                    
NuGet\Install-Package HiSocket -Version 2.7.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HiSocket" Version="2.7.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HiSocket" Version="2.7.3" />
                    
Directory.Packages.props
<PackageReference Include="HiSocket" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HiSocket --version 2.7.3
                    
#r "nuget: HiSocket, 2.7.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HiSocket@2.7.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HiSocket&version=2.7.3
                    
Install as a Cake Addin
#tool nuget:?package=HiSocket&version=2.7.3
                    
Install as a Cake Tool

HiSocket

It is a lightweight socket solution, you can used it in Unity3d or C# project

Packagist Build Status GitHub release


中文说明

How to use

You can choose use NuGet package, dll or source code, add it to your project.(The easiest way how to use HiSocket is via the HiSocket NuGet package)

Quick Start:

        //tcp example
        private IPackage package = new PackageExample();
        private TcpConnection tcp;
        void Init()
        {
            tcp = new TcpConnection(package);
            tcp.OnConnected += OnConnected;
            tcp.OnReceive += OnReceive;
            //...
            //...
            tcp.Connect("127.0.0.1",999);
        }
        void OnConnected()
        {
            //connect success
            tcp.Send(new byte[10]);//send message
        }

        void OnReceive(byte[] bytes)
        {
            //get message from server
        }

More example:


General

This project contains:

  • Connection
    • TcpConnection
      • TcpSocket
      • Package
    • UdpConnection
      • UdpSocket
    • Plugin
  • Message
    • Message register
    • Aes encryption
    • Byte message
    • Protobuf message

Features

  • Support Tcp socket
  • Support Udp socket
  • Scalable byte Array
  • High-performance byte block buffer
  • Message registration and call back
  • Support byte message
  • Support protobuf message
  • AES encryption

Details

  • Tcp and Udp are all use async connection in main thread(avoid thread blocking).
  • High-performance buffer avoid memory allocation every time, and reduce garbage collection.
  • You can get current connect state and message by adding listener of event.
  • If you use Tcp socket, you should implement IPackage interface to pack or unpack message.
  • If you use Udp socket, you should declaring buffer size.
  • Ping: there is a ping plugin you can used, but if you are used in unity3d because of the bug of mono, it will throw an error on .net2.0(.net 4.6 will be fine, also you can use unity's api to get ping time)

Advanced

  • If you are clear about socket, you also can use TcpSocket(UdpSocket) to achieve your logic, anyway the recommend is TcpConnection(UdpConnection).
  • You can use API get socket and do extra logic, for example modify time out time
  • You can use API get send and receive buffer, for example when disconnect should send all send buffer's data to server? or when reconnect how to process send buffer's data
  • OnSocketReceive and OnReceive are diffrent, for example OnSocketReceive size is 100 byte, if user do nothing when uppack OnReceive size is 100. but when user do some zip/unzip(encription.etc) OnReceive size is not 100 anymore.
  • You can add many different plugins based on TcpConnection(UdpConnection) to achieve different functions.
  • There are a message register base class help user to quick register id and callback(based on reflection)
  • Byte block buffer reuse block when some block is free.
  • .etc
Product Compatible and additional computed target framework versions.
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.7.4 977 6/29/2019
2.7.3 969 9/25/2018

Summary of changes made in this release of the package.