Giter Site home page Giter Site logo

supersocket.clientengine's Introduction

SuperSocket.ClientEngine Build Status NuGet Version

SuperSocket.ClientEngine is a .NET library for socket client rapid development. It provides easy to use and efficient APIs to simplify your socket development work about asynchronous connecting, data sending, data receiving, network protocol analysising and transfer layer encryption.

Build from Source Code

1. Download source code from Github or clone the repository;
2. Restore dependencies using NuGet; (Latest NuGet Visual Studio extension will restore dependencies before build automatically. You also can follow [This NuGet doc](https://docs.nuget.org/consume/package-restore#package-restore-approaches) to do it manually.)
3. Choose a correct solution file to build;

Install from NuGet

PM> Install-Package SuperSocket.ClientEngine

Usage

Create your ReceiveFilter Implementation according Your Network Protocol

SuperSocket.ClientEngine provides some powerfull basic ReceiveFilter classes (under the namespace "SuperSocket.ProtoBase") to help you simplify your protocol analysis:

TerminatorReceiveFilter
BeginEndMarkReceiveFilter
FixedHeaderReceiveFilter
FixedSizeReceiveFilter
CountSpliterReceiveFilter

You should design your own ReceiveFilter according yoru protocol details base on the basic ReceiveFilters provided by SuperSocket.ClientEngine:

class MyReceiveFilter : TerminatorReceiveFilter<StringPackageInfo>
{
	public MyReceiveFilter()
	: base(Encoding.ASCII.GetBytes("||")) // two vertical bars as package terminator
	{
	}
	
	// other code you need implement according yoru protocol details
}

Create an Instance of EasyClient and Initialize it with the ReceiveFilter which is created in the previous step

var client = new EasyClient();

// Initialize the client with the receive filter and request handler
client.Initialize(new MyReceiveFilter(), (request) => {
	// handle the received request
	Console.WriteLine(request.Key);
});

Make a Connection and then Start the Communication

// Connect to the server
var connected = await client.ConnectAsync(new IPEndPoint(IPAddress.Parse("192.168.10.11"), 25));

if (connected)
{
	// Send data to the server
	client.Send(Encoding.ASCII.GetBytes("LOGIN kerry"));
}

supersocket.clientengine's People

Contributors

kerryjiang avatar moljac avatar chucklu avatar berdon avatar gorniv avatar jturpen avatar bigbearzhu avatar mattleibow avatar iseebi avatar schappel avatar bigsupersniper avatar leszekm1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.