Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

6 Commits

Repository files navigation

NetworkLibrary

Network library is a simple C# Network Library that takes the complication of managing a TCP/IP connections and includes many handy features.

Features

Network comes with the follow features:

Quick Start

When using Network Library, both the client and server share the same interface INetwork. As such, you can keep the core code almost the same, whether you're dealing with the server or the client.

Creating a server is very simple. Create an instance of ConnectionHost and run StartBroadcasting:

usingSystem;usingNetworkLibrary.Core;publicclassMainProgram{staticINetworktheConnection;publicstaticvoidMain(paramsstring[]args){//Create an instance of our host.theConnection=newConnectionHost(33050);//Run the listener.(theConnectionasConnectionHost).StartBroadcasting();Console.WriteLine("\nHost up and running. Press any key to quit.");//Prevent the program from closingConsole.ReadKey();}}

Creating a client is also simple:

usingSystem;usingNetworkLibrary.Core;publicclassMainProgram{staticINetworktheConnection;publicstaticvoidMain(paramsstring[]args){//Create an instance of our host.theConnection=newConnectionClient();//Connect to server.(theConnectionasConnectionClient).Connect("127.0.0.1",33050);Console.WriteLine("\nSucessfully connected. Press any key to quit.");//Prevent the program from closingConsole.ReadKey();}}

Sending events is also very easy. Just register a function with specific integer code:

intcode=0;//Code for this eventourNetworkConnection.RegisterEvent(code,eventThatShouldBeRun);/* ... */privatevoideventThatShouldBeRun(objectsource,NetworkEventArgsargs){Console.WriteLine(sourceasstring);}

After that, you can easily send this type of message by simply doing:

intcode=0;//Code for this eventconnection.SendEvent(code,"Hello World");

For more information, check out Establish Connection and Registering events.

Documentation

Full documentation on Network Library can be found on the wiki.

License

Network Library is licensed under the terms of the WTFPL, see the included LICENSE file.

About

C# Event based Network Library with syncing

Resources

Stars

6 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages