N
neutrondba
Hello,
I am running into a problem where if I instantiate a
DatagramSocket
on Red Hat Linux , the JAVA VM returns back the same port on
subsequent calls
of instantiating a DatagramSocket. I need to instantiate multiple
Datagram Sockets from the same Java VM because I have a multithreaded
client. Because it returns the same port for multiple clients the
responses that come back from a DNS server returns results to the
incorrect client. This problem does not occur on Winows machines
I made a simple test of instantiating multiple times and found this to
be the case
while (true){
try {
clientSocket = new DatagramSocket();
System.out.println(" local " + clientSocket.getLocalPort());
timeSocket.close();
}
catch (SocketException excpt) {
System.err.println("Unable to bind UDP socket: " +
excpt);
System.exit(1);
}
try{
Thread.sleep(100);
}catch(Exception e){
}
}
[ classes]# java -classpath . tutorial.ClientSocket
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
Anyone have any ideas why it is returning the same port for each
instantiaton?
I am running into a problem where if I instantiate a
DatagramSocket
on Red Hat Linux , the JAVA VM returns back the same port on
subsequent calls
of instantiating a DatagramSocket. I need to instantiate multiple
Datagram Sockets from the same Java VM because I have a multithreaded
client. Because it returns the same port for multiple clients the
responses that come back from a DNS server returns results to the
incorrect client. This problem does not occur on Winows machines
I made a simple test of instantiating multiple times and found this to
be the case
while (true){
try {
clientSocket = new DatagramSocket();
System.out.println(" local " + clientSocket.getLocalPort());
timeSocket.close();
}
catch (SocketException excpt) {
System.err.println("Unable to bind UDP socket: " +
excpt);
System.exit(1);
}
try{
Thread.sleep(100);
}catch(Exception e){
}
}
[ classes]# java -classpath . tutorial.ClientSocket
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
local 32903
Anyone have any ideas why it is returning the same port for each
instantiaton?