Menu

How to find out what port one is running on

Help
Yaron
2013-11-01
2014-01-02
  • Yaron

    Yaron - 2013-11-01

    Right now one sets ARG_PORT and off one goes to the races. But we are using TJWS in circumstances where we don't care what port we get, just one that is available. The traditional way to do this is by passing in port 0. The socket will then just pick whatever port is available. I tested this with both the standard acceptor and the SSLAcceptor and it worked just fine (at least on Android but this is standard behavior in Java I believe).

    But the problem is - how do we find out what port we got?

    My short term plan is to just use our own versions of the standard and SSL acceptor that detect when ARG_PORT is 0 and after a socket is opened with a port resetting ARG_PORT to the value selected. But it would be really nice if this was standardized behavior.

    What do you think?

                Thanks,
    
                                Yaron
    
     
  • Yaron

    Yaron - 2013-12-23

    tldr-Can socket in SimpleAcceptor please be made protected?

    Long Winded Version -

    Btw, if anyone cares, the way I 'solved' this problem turned into a tiny bit of a mess.

    I came up with my own class that projects out status information like bound port in a 'safe' way from the socket.

    In the case of the SSLAcceptor the socket member is protected so I could inherit from SSLAcceptor and build my functionality on top. Easy enough.

    But for some reason the socket member in SimpleAcceptor is private. I didn't want to use reflection so my short term solution is that I copied the entire class source into a new class and added support for getting the port from the socket from there. That is a real bummer. Any chance SimpleAcceptor's socket member can be made protected?

    Thanks!

     
  • Д Рогаткин

    Sorry, busy with other projects, so even didn't release a version with certain critical fixes. I plan to move the repository to GitHub after Christmas so will make your life easier.

     
    • Yaron

      Yaron - 2013-12-25

      That's awesome! Then I can start submitting pull requests. :)

      From: "Д Рогаткин" [mailto:drogatkin@users.sf.net]
      Sent: Monday, December 23, 2013 8:59 PM
      To: [tjws:discussion]
      Subject: [tjws:discussion] How to find out what port one is running on

      Sorry, busy with other projects, so even didn't release a version with certain critical fixes. I plan to move the repository to GitHub after Christmas so will make your life easier.


      How to find out what port one is running onhttps://sourceforge.net/p/tjws/discussion/110264/thread/0752f5eb/?limit=25#d9b0


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/tjws/discussion/110264/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
  • Д Рогаткин

    Source control repository is now public available. See news. I didn't test it carefully, so any feedback is welcome.

     
    • Yaron

      Yaron - 2014-01-02

      I'll play with it in a bit. Do I need any build instructions since I've never used 7Bee before?

      Any chance 2.0 will use Gradle?

                  Thanks!!!
      
                                                  Yaron
      

      From: "Д Рогаткин" [mailto:drogatkin@users.sf.net]
      Sent: Monday, December 30, 2013 12:02 PM
      To: [tjws:discussion]
      Subject: [tjws:discussion] How to find out what port one is running on

      Source control repository is now public available. See news. I didn't test it carefully, so any feedback is welcome.


      How to find out what port one is running onhttps://sourceforge.net/p/tjws/discussion/110264/thread/0752f5eb/?limit=25#a806


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/tjws/discussion/110264/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.