Coder Social home page Coder Social logo

peer2net's Introduction

Open.P2P

Build status

NuGet version

Open.P2P is a lightweight and easy-to-use class library to develop peer-to-peer applications in .NET and Mono. Programming with sockets, and using tcp as communication protocol in particular, introduces some complexites which can be abstracted away.

Goals

The main goal is to simplify communication amoung computers abstracting away most of the complexities developers find when develop with sockets, providing a clean and easy interface to connect, disconnect, send and receive data to/from peers.

Example

A simple Echo service that once received a message, sends it back.

var listener = new Listener(9988);
var comManager = new CommunicationManager(_listener);

comManager.PeerConnected += (s, e)=> {
    using(var sr = new StreamReader(e.Peer.Stream))
	{
		using(var sw = new StreamWriter(e.Peer.Stream))
		{
			var read = sr.Read(buf, 0, buf.Length)
			while(read > 0)
			{
				sw.Write(buf, 0, read);
				read = sr.Read(buf, 0, buf.Length);
			}
		}
	}
};
listener.Start();

API

The main functionality is available trought the CommunicationManager class and its four methods: Connect, Disconnect, Send and Receive.

alt tag

Points of interest

Other goals are:

  • Avoid multi-threading. It uses a single thread approach to handle all the asynchronous operations and queue the communications' results in a independent queue for processing.
  • Reduce memory fragmentation: It implements its own buffer allocation mecanism to help the garbage collector to deal with pinned memory.
  • Low-memory usage. Internally, pooled objects and pre-allocated buffers are used to reduce the memory requirements.
  • Low-grained bandwidth control. It allows to control the individual peer's upload and download rates.

Development

Open.P2P is developed by Lucas Ontivero (@lontivero). You are welcome to contribute code. You can send code both as a patch or a GitHub pull request.

Note that Peer2Net is still very much work in progress.

peer2net's People

Contributors

lontivero avatar

Watchers

James Cloos avatar Eric avatar  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.