UDP broadcasts and ServerSockets port confliction

myUDP broadcast port seems to randomly

conflict with myServerSockets.

some times its ok.

other times i getBindExceptions. it makes no

sense. now, here is the code:

byte[] message ="is there anyone out there".getBytes();

InetAddress addr = InetAddress.getByName("255.255.255.255");

DatagramPacket packet =new DatagramPacket(message, message.length, addr, 5511);

DatagramSocket dataSok =new DatagramSocket();

dataSok.send(packet);

and here is theServerSocket code:

ServerSocket servSok =new ServerSocket(5510);

here is the stack trace:

java.net.BindException: Address already in use: JVM_Bind

at java.net.PlainSocketImpl.socketBind(Native Method)

at java.net.PlainSocketImpl.bind(Unknown Source)

at java.net.ServerSocket.bind(Unknown Source)

at java.net.ServerSocket.<init>(Unknown Source)

at java.net.ServerSocket.<init>(Unknown Source)

at client.ServDiscovery$Registrar.run(ServDiscovery.java:161)

ialways use different ports.always.

yet, i get theseBindExceptions sometimes,

sometimes its fine.

note: i am usingEclipse, and if this is

anEclipse issue, i'm going to be very very

angry, upset, and sad.

i am so confused.

what is going on?

couldUDP packets be bouncing around my

LAN withTTL issues?

[1699 byte] By [dew2hirooa] at [2007-11-27 3:27:58]
# 1

>

> i always use different ports. always.

> yet, i get these BindExceptions sometimes,

> sometimes its fine.

Err... different ports for what? If for the ServerSocket then why are you doing this? You do of course realize that other applications could be using some of these 'different ports'.

>

> note: i am using Eclipse, and if this

> is

> an Eclipse issue, i'm going to be very very

> angry, upset, and sad.

The standard response to problems people don't understand - blame the tools.

>

> i am so confused.

> what is going on?

> could UDP packets be bouncing around my

> LAN with TTL issues?

Eh!

How are UDP and your ServerSockets (which use TCP) going to clash?

sabre150a at 2007-7-12 8:30:46 > top of Java-index,Core,Core APIs...
# 2

> >

> > i always use different ports.

> > yet, i get these BindExceptions sometimes,

> > sometimes its fine.

>

> Err... different ports for what? If for the

> ServerSocket then why are you doing this? You do of

> course realize that other applications could be using

> some of these 'different ports'.

i change ports as soon as the phenonmenon starts.

a machine sends out a 1 to all UDP broadcast

on a LAN. then all machines listening on the port call

back to the machine by opening a Socket with

ServerSocket. ConnectionPools are then created.

> > what is going on?

> > could UDP packets be bouncing around my

> > LAN with TTL issues?

>

> Eh!

>

> How are UDP and your ServerSockets (which use TCP)

> going to clash?

if you look at the error report, it looks like the UDP broadcast

and ServerSocket might be trying to claim the same port on the

same machine.

i am going to run on jvms outside of the Eclipse abstraction.

and on a different LAN with different machines with different OS.

java is designed for networking, so java can't be the problem.

just consider this closed. its too strange.

dew2hirooa at 2007-7-12 8:30:46 > top of Java-index,Core,Core APIs...
# 3

> if you look at the error report, it looks like the

> UDP broadcast

> and ServerSocket might be trying to claim the

> same port on the

> same machine.

>

They are allowed to use the same port because UDP ports and TCP ports are independent.

P.S. Why do you open a ServerSocket on each machine?

sabre150a at 2007-7-12 8:30:46 > top of Java-index,Core,Core APIs...
# 4

> > if you look at the error report, it looks like the

> > UDP broadcast

> > and ServerSocket might be trying to claim

> the

> > same port on the

> > same machine.

> >

>

> They are allowed to use the same port because UDP

> ports and TCP ports are independent.

>

> P.S. Why do you open a ServerSocket on each machine?

its peer-to-peer.

all machines are clients and servers

anyway, this just can't be a java issue.

i should not have posted.

i'm off to a 100% new environment.

dew2hirooa at 2007-7-12 8:30:46 > top of Java-index,Core,Core APIs...
# 5

sabre150 and everyone that looked at this port, thanks for your reading.

i do not mean to discount that.

i think i got it.

i'm 70% sure its Eclipse.

the results vary depending on how i crash out

of the Console.

i don't think Eclipse does exactly this everytime

i re-run my application:

javac *java

java MainClient

but maybe it does?

yet, do to the abstraction, i can't say for sure.

i think Eclipse does a virtual reset.

i think this effected my

ClassLoader awhile back also.

Message was edited by:

dew2hiroo

dew2hirooa at 2007-7-12 8:30:46 > top of Java-index,Core,Core APIs...