Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Usage of Socket's bind() method.

Thread view: 
Daniel M. - 15 Feb 2006 19:08 GMT
Hello everybody.

Why does the Socket class have a bind() method and how/what it
is used for - after all, Socket class implements only client's
socket, so it doesn't accept connections (and therefore doesn't
have an accept() method, like ServerSocket) and connection to a
server is establshed by calling connect(), so what does bind()
do?
Rob Skedgell - 16 Feb 2006 00:08 GMT
> Hello everybody.
>
[quoted text clipped - 4 lines]
> server is establshed by calling connect(), so what does bind()
> do?

You can create an unconnected Socket using the default constructor, then
use Socket.bind(SocketAddress) to use a specific (local) InetAddress
and port to connect *from*. You might want to use some of Socket's
setXXX methods to set other things before you connect it to the
endpoint using Socket.connect(SocketAddress).

Signature

Rob Skedgell <rob+news@nephelococcygia.demon.co.uk>
GnuPG/PGP: 7DA3 1579 C0DD 8748 C05A  B984 E2A2 3234 D14B 6DD7



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.