Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Free up port(s)

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Free up port(s)

    Hello everybody,

    anybody could say me how to free up a port (for instance 8088) which is used by other user (in other Windows 7 session in same computer).
    The trouble is that I have a java application in both sessions, but the port in which the app is listening is same, so after the have been ocuped by the first user, the second one can not use it because it is not free.

    I would need a code.

    My first idea was kill the app of the first user, but from the other session in impossible to kill process of the first one. Thats why now I am thinking about just to free up the port when the app take control in whatever session/user...

    Any idea??

    Thank you in advance


  2. #2
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Free up port(s)

    It could be feasible get the socket (which is using the port) from the port number (is the only info I have), and then close the socket and unbind/free up the port?

    What about this?

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Free up port(s)

    Hello again,

    I got a method to manage the case in which the user logoff the computer. It is using addShutdownHook(). An example:


    Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
    System.out.println("Inside Add Shutdown Hook");
    }
    });

    It works really good.

    For the moment I have absolutely no idea how manage the user switching. Just needed a listener or a handle of users switchings!! But I dont find anything!!!!

    --- Update ---

    If I get a way to manage when a switch/wakeup/hibernate, etc takes place I could close the port and open again with the other user....I mean, at the end is same that free up the port...

Similar Threads

  1. Any free jar to exe free ware there to use?
    By tangara in forum Java SE APIs
    Replies: 1
    Last Post: May 14th, 2013, 08:18 AM
  2. [ask]port unreachable
    By clavius11 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 6th, 2013, 05:52 AM
  3. Relay data from remote port to local port
    By chegers in forum Java Networking
    Replies: 0
    Last Post: November 7th, 2010, 12:46 PM
  4. Port issue?
    By Brt93yoda in forum Java Theory & Questions
    Replies: 3
    Last Post: October 13th, 2010, 04:28 PM