1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.example.sctp;
17
18 import io.netty.bootstrap.Bootstrap;
19 import io.netty.channel.ChannelFuture;
20 import io.netty.channel.ChannelInitializer;
21 import io.netty.channel.EventLoopGroup;
22 import io.netty.channel.nio.NioEventLoopGroup;
23 import io.netty.channel.sctp.SctpChannel;
24 import io.netty.channel.sctp.SctpChannelOption;
25 import io.netty.channel.sctp.nio.NioSctpChannel;
26
27
28
29
30
31
32
33
34
35 public final class SctpEchoClient {
36
37 static final String HOST = System.getProperty("host", "127.0.0.1");
38 static final int PORT = Integer.parseInt(System.getProperty("port", "8007"));
39 static final int SIZE = Integer.parseInt(System.getProperty("size", "256"));
40
41 public static void main(String[] args) throws Exception {
42
43 EventLoopGroup group = new NioEventLoopGroup();
44 try {
45 Bootstrap b = new Bootstrap();
46 b.group(group)
47 .channel(NioSctpChannel.class)
48 .option(SctpChannelOption.SCTP_NODELAY, true)
49 .handler(new ChannelInitializer<SctpChannel>() {
50 @Override
51 public void initChannel(SctpChannel ch) throws Exception {
52 ch.pipeline().addLast(
53
54 new SctpEchoClientHandler());
55 }
56 });
57
58
59 ChannelFuture f = b.connect(HOST, PORT).sync();
60
61
62 f.channel().closeFuture().sync();
63 } finally {
64
65 group.shutdownGracefully();
66 }
67 }
68 }