My specific problem is I have a tomcat comet servlet that my java application connects to. For some reason, I am getting random END events and I cant figure out why. I wonder, as Im trying to weed out whats not wrong, is if windows when connecting to the same ip and port, from within the same jvm, would give two processes the same port? This would make it look like to the server that the connection is coming from the same place? Does it work this way? I open two instances of the application from netbeans, the same JVM, and Im wondering if this can occur?
2 Answers
I wonder, as Im trying to weed out whats not wrong, is if windows when connecting to the same ip and port, from within the same jvm, would give two processes the same port?
No. Windows will always allocate a new local port for outbound connections.
This would make it look like to the server that the connection is coming from the same place? Does it work this way?
No.
I open two instances of the application from netbeans, the same JVM, and Im wondering if this can occur?
No.
The bug referred to in @TapanPandya's answer concerns ServerSockets
and explicit bind()
invocations. It isn't relevant to outbound connections.

- 305,947
- 44
- 307
- 483
There was a bug in Java 7 some time back which allowed multiple applications to use same port. JDK-7179799. Also, check similar question Can two applications listen to the same port

- 1
- 1

- 114
- 2
-
1Two programs listening at a specific port has nothing to do with what Windows does when allocating a system-allocated outbound port. – user207421 Aug 05 '14 at 05:06