Skip to content

ArturD/Daemons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Daemons

Simple tcp server example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using Daemons.IO;
using Daemons.Net;

namespace Daemons.EchoServerExample
{
    class Program
    {

        static void Main(string[] args)
        {
            var tcpServer = new TcpServer();
            tcpServer.Listen<EchoReactor>(new IPEndPoint(IPAddress.Any, 1234));
            Console.ReadLine();
        }
    }

    class EchoReactor : BufferedReactor
    {
        protected override void NewDataInBuffer()
        {
            var buffer = Buffer.TakeAsArray(Buffer.Count);
            Stream.Write(buffer, () => { });
        }

        protected override void BufferIsFull()
        {
            throw new InvalidOperationException("To much data, must die.");
        }
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages