Search Wiki:
Resource Page Description
Asynchronous Servers created using C# and XF.Server API.
Network events are processed using I/O completion port.

XF.Server Network API Examples

This simple examples demonstrates the power of network API which helps to creates IOCP Server just in seconds.

Simple Asynchronous C# Server Example
using System;
using System.Net;
using System.Text;
using XF;
 
namespace Demo
{
    class Program
    {
        static void Main()
        {
            using (var listener =
                Network.AcceptAsync(
                    new IPEndPoint(IPAddress.Any, 80),
                    connection => connection.ReadAsync((ignore, buffer, bytesReceived) =>
                    {
                        connection.Close(); //data received, close connection
                        Console.WriteLine(Encoding.ASCII.GetString(buffer.Data, buffer.Offset, bytesReceived));
                    })))
            {
                Console.WriteLine("XF.Server is ready to accept connections at {0}.", listener.EndPoint);
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey(true);
            }
        }
    }
}

Asynchronous C# Echo Server Example
using System;
using System.Net;
using XF;
 
namespace Demo
{
    class Program
    {
        static void Main()
        {
            using (var listener =
                Network.AcceptAsync(
                    new IPEndPoint(IPAddress.Any, 80),
                    connection => connection.ReadAsync((ignore, buffer, bytesReceived) =>
                       {
                           if (bytesReceived <= 0) return;
                           connection.WriteAsync(buffer.Data, buffer.Offset, bytesReceived);
                       })))
            {
                Console.WriteLine("XF.Echo Server is ready to accept connections at {0}.", listener.EndPoint);
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey(true);
            }
        }
    }
}

For more information please refer to http://www.kodart.com
Last edited Oct 13 2008 at 1:57 AM  by ash, version 5
Comments
spamcorp wrote  Jun 23 2009 at 4:11 AM  
XF.Server is extremely limited and It's not even open source. :[

ash wrote  Jun 25 2009 at 7:24 AM  
Yes it is not open source, but they have community license, which is free. What features do you need? It looks like it does the job, or not?

ff wrote  Mar 9 2012 at 9:20 AM  
it's the demo can't . maybe nobody used it

??????: System.IO.FileLoadException: ??????????“XF.Server, Ver
sion=2.0.3201.4371, Culture=neutral, PublicKeyToken=null”???????????
??????????,??????????????????????????? (?
??? HRESULT:0x800736B1)
???:“XF.Server, Version=2.0.3201.4371, Culture=neutral, PublicKeyToken=null
” ---> System.Runtime.InteropServices.COMException (0x800736B1): ???????
????,??????????????????????????? (???? HRESU
LT:0x800736B1)
? Demo.Program.Main()

Updating...
Page view tracker