hunt-net 0.4.0-rc.4

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.

Use 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 ConnectionEventHandler
    {
        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);
}

Use 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 ConnectionEventHandler
    {
        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, hunt-security
Versions:
0.4.0-rc.4 2019-Sep-11
0.4.0-rc.3 2019-Aug-09
0.3.6 2019-Aug-05
0.2.2 2019-Apr-03
0.1.0 2019-Jan-25
Show all 8 versions
Download Stats:
  • 0 downloads today

  • 26 downloads this week

  • 41 downloads this month

  • 1165 downloads total

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