Limiting number of ports in VM to a range

H

Hung

Hi there,

Trying to setup a vm server which accepts incoming connections. Is
there a way of limiting the range of clients ports used by the vm
during the connection creation with the connecting clients?

I've looked at SocketPermissions, it looks like what I want...but
not 100% sure.
 
G

Gordon Beaton

Trying to setup a vm server which accepts incoming connections. Is
there a way of limiting the range of clients ports used by the vm
during the connection creation with the connecting clients?

No, you need to accept all incoming connections, but you can close the
ones you don't like based (for example) on Socket.getPort(). I wonder
however what added value this has, considering the complexity it adds
to the client.

The only thing similar to what you are asking is to bind your
ServerSocket to a specific local address, which lets you restrict what
network your clients can connect from.

/gordon
 
H

Hung

Sorry, I really meant the socket created via the accept() of the
connection from the client application.
So the socket on the same vm running the serversocket.
 
G

Gordon Beaton

Sorry, I really meant the socket created via the accept() of the
connection from the client application. So the socket on the same vm
running the serversocket.

Every Socket returned by ServerSocket.accept() uses the *same* local
port as the ServerSocket it came from.

Maybe you could try to describe what problem you're trying to solve,
instead of how you hope to solve it.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top