Skip to content

dotnet core version of SuperSocket

License

Notifications You must be signed in to change notification settings

913658084csp/SSCore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSCore

dotnet core version of SuperSocket. Pick up socket communication logic from SuperSocket, and exclude command concept.

usage

  1. Create SocketServerBase object
  2. Add handler for new client connection.
  3. Start the socket server object.
  4. Implement the handler of new client connection.
  5. Add handler for receiving message.

Example

class Program
{
    static void Main(string[] args)
    {
        SocketServerBase server = new SocketServerBase();
        server.NewClientAccepted += Server_NewClientAccepted;
        server.Start();

        Console.WriteLine("enter any key to exit.");
        Console.ReadKey();
    }

    private static void Server_NewClientAccepted(Socket client, ISocketSession session)
    {
        Console.WriteLine("----- new client ------------");
        AsyncSocketSession ass = session as AsyncSocketSession;

        ass.SetReceiveHandler(arg =>
        {
            Console.WriteLine("----- new receive ------------");
            string received = System.Text.Encoding.UTF8.GetString(arg.Buffer, arg.Offset, arg.BytesTransferred);
            Console.WriteLine(received);

            ass.Send(received);
        });
    }
}

About

dotnet core version of SuperSocket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%