hello ,
I didn't use bind ,because i didn't know what dose it work
i want to know what dose it use for?

thanks
Hamed
Posted on 2002-03-28 23:46:40 by hamed_hhz
Bind is used when you want to handle incoming connections, like in a server. Usually you use "bind" right before "listen". I don't really know why you have to call 2 functions for this, but I guess Microsoft has its reasons.
Posted on 2002-03-29 05:19:18 by Qweerdy
You bind the socket to a local ip adress. Lets say you have two network cards, one with ip 192.168.0.1 and one with a dynamic ip assigned by your ISP. When you write a server, depending on how you use bind() you can choose which NIC your server should listen on. So if you would bind the listen socket to 192.168.0.1 no one would be able to access your server from the internet. It would only be accessible from the LAN.

And MicroSoft had no reasons for doing it like that because they did not design the API. They simply adopted the API from the Unix world. The only winsock API calls MS designed are the ones starting with the letters WSA.

You can also use bind before sending data to set source port instead of having the OS assign you a dynamic one. And if you plan on doing UDP communication i think you have to bind() before sending data if you want to get a reply...

So use bind(), it's good programming ;)
Posted on 2002-03-29 06:16:38 by Zynaps
You use sockets simply because everyone uses it. This is not like graphics where you have a choice. Either you use it, or people simply don't use your software.

BTW. Good luck trying to figure out another way.
Posted on 2002-03-31 04:00:47 by eet_1024