hunt net
v0.7.1
헌트 라이브러리 기반의 DLang용 넷 라이브러리입니다. Hunt-net에는 TCP 스트리밍 프레임을 인코딩하고 디코딩하는 코덱이 있습니다.
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 );
}
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 );
}