Binding of a server socket to an address that is not a localhostaddress
I have been using Sockets to establish communication between the 2 classes.
I have a class x1 which is reqd to communicate with either one of the several receiving classes a1,a2,a3...
Currently, i'm biniding the server sockets of the receiving classes, to different ports, and am passing the port mumber as a parameter to the x1 class..
So the socket in x1, and that particular server socket bound to the respective port will be in communication.
=> Is it possible for me to use ip addresses instead of ports?
=> I tried to bind a server socket to an address which wasn't the localhost address. I'm getting an exception,
" java.net.BindException: Cannot assign requested address: JVM_Bind "
Is it not possible to do so?
Last edited by aadgod; 03-26-2009 at 04:53 PM.
as far as I can remember you can bind to the localhost, and that is mapped to a physical ip address by the operating system, which in turn is generally bound to a network card/adapter.
So if you had two network adapters then you could bind two ip addresses.
This is unusual however, its more usual to have a single ip address and use different port numbers
Hope this helps
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, and if they get mad, you are a mile away and you have their shoes ;-)
thank you sir JRobinson...
Last Post: 08-30-2008, 03:03 PM
By imranx101 in forum .NET
Last Post: 06-13-2008, 11:32 AM
Last Post: 05-15-2008, 01:56 AM
By Alan Shiers in forum Java
Last Post: 09-19-2000, 11:57 AM
Last Post: 07-24-2000, 02:18 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL