hunt-net 0.5.5
A network library for hunt.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
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 AbstractNetConnectionHandler
{
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 AbstractNetConnectionHandler
{
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);
}
- Registered by zoujiaqing
- 0.5.5 released a month ago
- huntlabs/hunt-net
- www.huntlabs.net
- Apache-2.0
- Copyright (C) 2018-2020, HuntLabs
- Dependencies:
- hunt-extra
- Versions:
-
0.6.0 2021-Jan-26 0.5.10 2021-Jan-26 0.5.9 2021-Jan-13 0.5.8 2021-Jan-12 0.5.7 2021-Jan-08 - Download Stats:
-
-
9 downloads today
-
21 downloads this week
-
95 downloads this month
-
3187 downloads total
-
- Score:
- 1.7
- Short URL:
- hunt-net.dub.pm