Richeve Bebedor
Richeve Bebedor

Reputation: 1658

Java Socket Issue

I'm gonna use Socket() constructor to create a 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?

Upvotes: 0

Views: 63

Answers (1)

Roland Illig
Roland Illig

Reputation: 41625

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.

Upvotes: 1

Related Questions