java - Bootstrap class doesn't have method (String host, int port) -



java - Bootstrap class doesn't have method (String host, int port) -

trying create test client - server application , faced problem this

channel channel = bootstrap.connect(host, port).sync().channel();

bootstrap's class doesn't have method connect arg types string, int. how can obtain channel?

public class chatclient { private final string host; private final int port; public static void main(string[] args) throws exception{ new chatclient("localhost", 8080).run(); } public chatclient(string host, int port) { this.host = host; this.port = port; } public void run() throws exception { eventloopgroup grouping = new nioeventloopgroup(); try{ bootstrap bootstrap = new bootstrap() .group(group) .channel(niosocketchannel.class) .handler(new chatclientinitializer()); channel channel = bootstrap.connect(host, port).sync().channel(); bufferedreader in = new bufferedreader(new inputstreamreader(system.in)); while(true){ channel.write(in.readline() + "\r\n"); } } finally{ } } }

took sample here https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/securechat/securechatclient.java

thanks in advance

its has... sure depend on right netty version 4+.

see: https://github.com/netty/netty/blob/4.0/transport/src/main/java/io/netty/bootstrap/bootstrap.java#l95

java networking netty

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -