Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huntlabs/hunt-net
High-performance network library for D programming language, event-driven asynchonous implemention(IOCP / kqueue / epoll).
https://github.com/huntlabs/hunt-net
codec socket ssl tcp tls udp
Last synced: 1 day ago
JSON representation
High-performance network library for D programming language, event-driven asynchonous implemention(IOCP / kqueue / epoll).
- Host: GitHub
- URL: https://github.com/huntlabs/hunt-net
- Owner: huntlabs
- License: apache-2.0
- Created: 2018-06-15T09:41:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-21T06:18:34.000Z (over 2 years ago)
- Last Synced: 2024-08-04T01:03:16.924Z (3 months ago)
- Topics: codec, socket, ssl, tcp, tls, udp
- Language: D
- Homepage:
- Size: 1.01 MB
- Stars: 21
- Watchers: 5
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-d - hunt-net - High-performance network library for D programming language, event-driven asynchonous implemention(IOCP / kqueue / epoll). (Web Frameworks / Bare metal / kernel development)
README
[![Build Status](https://travis-ci.com/huntlabs/hunt-net.svg?branch=master)](https://travis-ci.com/huntlabs/hunt-net)
# 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
```D
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
```D
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);
}
```