Limiting number of ports in VM to a range

Discussion in 'Java' started by Hung, Feb 27, 2007.

  1. Hung

    Hung Guest

    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.
    Hung, Feb 27, 2007
    #1
    1. Advertising

  2. On 27 Feb 2007 09:55:28 -0800, Hung wrote:
    > 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

    --
    [ don't email me support questions or followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Feb 27, 2007
    #2
    1. Advertising

  3. Hung

    Hung Guest

    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.


    On Feb 27, 1:24 pm, Gordon Beaton <> wrote:
    > On 27 Feb 2007 09:55:28 -0800, Hung wrote:
    >
    > > 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
    >
    > --
    > [ don't email me support questions or followups ]
    > g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Hung, Feb 27, 2007
    #3
  4. On 27 Feb 2007 10:28:25 -0800, Hung wrote:
    > 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

    --
    [ don't email me support questions or followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Feb 27, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jp Calderone
    Replies:
    0
    Views:
    929
    Jp Calderone
    Jun 28, 2005
  2. mreister
    Replies:
    1
    Views:
    3,159
    mreister
    May 25, 2010
  3. Limiting number of control instances?

    , Apr 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    113
    Zarko Gajic
    Apr 26, 2005
  4. bj
    Replies:
    1
    Views:
    125
    Scott McNair
    Apr 16, 2004
  5. Darren
    Replies:
    0
    Views:
    87
    Darren
    Jul 13, 2003
Loading...

Share This Page