aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Reproducing BindException in windows environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Reproducing BindException in windows environment " Watch "Reproducing BindException in windows environment " New topic
Author

Reproducing BindException in windows environment

Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
hi...

for a while now we are stubmling on a strange bug which seems to only happen in linux, which is a bindException, a socket server fails when tries to bind to a port on a linux machine, but does not do so in a windows. both jvm's are of sun, same version same build. (1.6.0_25)

so what's the difference?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18853
    
  40

Elhanan Maayan wrote:hi...

for a while now we are stubmling on a strange bug which seems to only happen in linux, which is a bindException, a socket server fails when tries to bind to a port on a linux machine, but does not do so in a windows. both jvm's are of sun, same version same build. (1.6.0_25)

so what's the difference?



Well, there are two obvious differences. First, one is on a linux machine and the other on a windows machine. These are two different OSes, which have different services -- so a port that is free on one machine may not be on the other machine (due to service configurations).

And second, the sockopts are different. If the bind error is caused by an application bounce, one possibility is the TCP timeout -- it may be a good idea to set the TCP NODELAY to allow better reuse of the ports.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
the ports were not taken , this is because the application DID manage to bind to the port initially, i've found out, if i wait 10 ms in linux then i can bind to the port, if i try to close and open and it fails (but not always)

and reuse property was used.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18853
    
  40

Elhanan Maayan wrote:the ports were not taken , this is because the application DID manage to bind to the port initially, i've found out, if i wait 10 ms in linux then i can bind to the port, if i try to close and open and it fails (but not always)

and reuse property was used.



The purpose of TCP_NODELAY is to allow the bounce without having to wait for the socket timeout. So, if reuse was set properly, it should work.

Henry
Elhanan Maayan
Ranch Hand

Joined: May 04, 2009
Posts: 113
maybe it allows it in windows, but in linux it's different?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18853
    
  40

Elhanan Maayan wrote:maybe it allows it in windows, but in linux it's different?


I use it all the time -- with both Linux and Windows -- it works fine.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reproducing BindException in windows environment