开发者

Java Socket Issue

开发者 https://www.devze.com 2023-02-10 11:01 出处:网络
I\'m gonna use Socket() constructor to create 开发者_如何学JAVAa dummy like socket. what is the difference of using bind() and connect() to this created socket?

I'm gonna use Socket() constructor to create 开发者_如何学JAVAa dummy like socket.

what is the difference of using bind() and connect() to this created socket?

if i'm gonna use bind() how can i establish connection or does it directly establish connection?


With a socket you build a connection between two endpoints. One of these endpoints (the local one) is on your machine, the other endpoint (the remote one) may be anywhere.

With bind you set the address of the local endpoint. Often you don't need to do that, since your operating system will take care of the details.

With connect you set the address of the remote endpoint and start a connection.

0

精彩评论

暂无评论...
验证码 换一张
取 消