hunt-net 0.4.5

A network library for hunt.


To use this package, run the following command in your project's root directory:

Build Status

hunt-net

A net library for DLang, hunt library based. hunt-net have codec to encoding and decoding tcp streaming frames.

Using codec to build a TcpServer

import hunt.net;
import hunt.net.codec.textline;

import hunt.logging;

void main()
{
    NetServerOptions options = new NetServerOptions();
    NetServer server = NetUtil.createNetServer!(ThreadMode.Single)(options);

    server.setCodec(new TextLineCodec);
    server.setHandler(new class NetConnectionHandler
    {
        override void messageReceived(Connection connection, Object message)
        {
            import std.format;

            string str = format("data received: %s", message.toString());
            connection.write(str);
        }
    }).listen("0.0.0.0", 9999);
}

Using codec to build a TcpClient

import hunt.net;
import hunt.net.codec.textline;

import hunt.logging;

void main()
{
    NetClient client = NetUtil.createNetClient();

    client.setCodec(new TextLineCodec);
    client.setHandler(new class NetConnectionHandler
    {
        override void messageReceived(Connection connection, Object message)
        {
            import std.format;
            import hunt.String;

            string str = format("data received: %s", message.toString());
            
            connection.write(new String(str));
        }
    }).connect("localhost", 9999);
}

TODO

  • [ ] Improve support for SSL
  • [ ] Improve APIs
Dependencies:
hunt
Versions:
0.5.0 2020-May-21
0.4.13 2020-May-18
0.4.12 2020-May-12
0.4.11 2020-May-08
0.4.9 2020-Apr-26
Show all 16 versions
Download Stats:
  • 4 downloads today

  • 33 downloads this week

  • 177 downloads this month

  • 2149 downloads total

Score:
2.8
Short URL:
hunt-net.dub.pm