Examples of StringLineEncoder


Examples of test.net.tcp.example.StringLineEncoder

import com.firefly.net.support.wrap.client.TcpConnection;
import com.firefly.utils.log.LogFactory;

public class SimpleTcpClientExample {
  public static void main(String[] args) throws Throwable {
    final SimpleTcpClient client = new SimpleTcpClient("localhost", 9900, new StringLineDecoder(), new StringLineEncoder(), new PipelineClientHandler());
    long start = System.currentTimeMillis();
    TcpConnection c = client.connect().get();
    long end = System.currentTimeMillis();
    System.out.println("connection 0 creating time is " + (end - start));
    System.out.println("current conn id: " + c.getId());
View Full Code Here

Examples of test.net.tcp.example.StringLineEncoder

  @Test
  public void testHello() throws Throwable {
    Server server = new TcpServer();
    Config config = new Config();
    config.setDecoder(new StringLineDecoder());
    config.setEncoder(new StringLineEncoder());
    config.setHandler(new SendFileHandler());
    server.setConfig(config);
    server.start("localhost", 9900);

    final int LOOP = 50;
    ExecutorService executorService = Executors.newFixedThreadPool(LOOP);
    final SimpleTcpClient client = new SimpleTcpClient("localhost", 9900, new StringLineDecoder(), new StringLineEncoder(), new PipelineClientHandler());

    for (int i = 0; i < LOOP; i++) {
      executorService.submit(new Runnable() {
        @Override
        public void run() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.