简体   繁体   中英

Difference between connect and bind in bootstrap : Netty

I am newbie to Netty framework and trying to understand its internals. My question is about BootStrap class for client and for connectionless protocols. I see two methods Connect( defined in BootStrap ) and Bind ( defined in AbstractBootStrap )

Since Bootstrap is child of AbstracBootStrap , it also has Bind method. I understand use Connect() to connect to remote server , why is Bind() needed for ?

bind and connect are TCP/IP concepts, which Netty uses because it is a server.

Connect is how you connect a local machine to a remote machine.

Bind is how you get the server to listen for remote connections on a port.

Check out this Oracle tutorial on Networking Basics:

https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html

You can first bind the local port/ip and the connect to the remote port. This basically allows you to do this in two steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM