Negotiating a port number from the OS

All the socket classes require a port number to be specified. No problem, except as one of the requirements at work, I need to make a server that negotiates with the OS to receive a free port number. I can not hard code any numbers or receive them from the command line. I've looked through the forums and a few google searches, but I can't find anything useful. Does anyone here know how to do this or what technologies can do this? This requirement was kinda sprung on at the last minute, so even a simple hack may be exceptable. Thanks alot.
-JBoeing

That's easy, bind the serversocket to port "0", it
will do exactly what you want.http://java.sun.com/j2se/1.4.1/docs/api/java/net/ServerSocket.html#ServerSocket(int)
see the first sentence:
Creates a server socket, bound to the specified port. A port of 0 creates a socket on any free port.
Regards Vaclav

Similar Messages

  • How to hide the PORT NUMBER from the URL

    Hi,
    We have Application on Node 1 and Database on Node 2
    Apps Version: 11.5.10.2
    DB: 9.2.0.6
    We recently added a new node to act as web server for iSupport.
    Now we are able to access the url using public Ip-address which looks like
    http://<Internet Ip-Address>:<PORT NUMBER>
    Eg: http://******.com:8000
    But we dont want the *'PORT NUMBER(8000)'* to be displayed.
    How to hide the port number ?..
    Thanks in Advance,
    Mahesh

    Hi Hsawwan,
    Can you plz explain me the steps how to hide the port number from the url as our network administrator is not aware of this.
    Regards,
    Mahesh

  • Hiding the port number from the url

    Hi All,
    In our applications built using Weblogic Portal 10.3, the url to access the application doesnt have the port number. It is simply like http://<server-name>/<context> no port at all. Is this some configuration that is available inside weblogic adminstration console? The domain has both the default port and the SSL port enabled which are running in 7001 and 7002 respectively. Please let me know as how to do this configuration as I am growing haywired on this it has been about a week and have not found an answer yet. Please throw some light on this and let me know if you need further details
    Thanks
    Ashwin

    you should install apache server to handle all the requests on port 80 and froward it to weblogic server using wlp plugin
    please check this link
    http://download.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/apache.html
    any request http://yourapp/context will be mapped to http://youapp:7001/context

  • Eliminating the port number from the URL

    Hi,
    I am using Tomcat server.
    I am accessing my application using the following url
    http://www.myapplication.com:9080/abc
    I wanted to eliminate the " :9080 " part from the url. I s it possible?
    I want the same page to open with the url
    http://www.myapplication.com/abc
    Thanks in advance.

    http://www.myapplication.com/abc
    implies
    http://www.myapplication.com:80/abc
    You would need to change your port from 9080 to 80

  • Select Listener Port Number from which_table?

    I'm writing a SQL script that, among other things, disconnects from Oracle and then reconnects to the same instance as a different user. I'm able to query v$database and v$instance to get most of the information I need (host, service name, etc) for the reconnect part. The only part I'm missing is the listener port number. I could hard code it to 1521, but that isn't very flexible. Currently, I'm prompting the user (which is normally me) for the listener port number in the SQL script, but that just seems a little bit lame. So my question is this: is there a view or table somewhere in the sys schema that I could use to view the listener configuration? I'm mostly working with 10gR2+ databases.

    cleavitt wrote:
    That is possible, but it needs to be a standard Oracle configuration if the script is to remain generic and portable. The script is actually working fine as-is. I was just trying to go the extra mile and determine the port number automatically. I could also prompt for a TNSNames entry as suggested by others, but I don't always have an entry defined for all of the Oracle instances in my company on every workstation that I work from.
    Here is the script for anyone that is interested. It started out as a script that I found online, but the original did not work with 11g case-sensitive passwords and it only worked for local connections on the server.
    Description:
    Allows a DBA user to impersonate another user (without knowing the user's password).
    Similar in function to using the SU command in Unix/Linux.
    Note:
    This script temporarily changes the impersonated user's password and may cause other
    connection attempts by that user to fail during the moment that the temporary password is in effect.
    WHENEVER SQLERROR EXIT
    SET VERIFY OFF
    ACCEPT username CHAR PROMPT 'Enter the username: '
    ACCEPT listenerport NUMBER DEFAULT 1521 PROMPT 'Enter the listener port [1521]: '
    -- Define substitution variables and column mapping.
    COLUMN username NEW_VALUE username
    COLUMN password_hash NEW_VALUE password_hash
    COLUMN host_name NEW_VALUE hostname
    COLUMN instance_name NEW_VALUE servicename
    -- Populate substitution variables.
    SELECT
    name AS username,
    -- Get the user's password hash(s) and apply appropriate formatting for case-sensitive password if needed (11g+ passwords).
    NVL2(spare4, spare4 || ';' || password /* 11g+ */, password /* pre-11g */) AS password_hash
    FROM sys.user$
    WHERE name = UPPER('&username');
    SELECT host_name, instance_name
    FROM v$instance;
    -- Set the user's password to a temporary value.
    ALTER USER &username IDENTIFIED BY TempPass;
    -- Use the temporary password to connect to the database as the user.
    CONNECT &username/TempPass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=&hostname)(PORT=&listenerport))(CONNECT_DATA=(UR=A)(SID=&servicename)));
    -- Reset the user's password to the original value using the original password hash(s).
    ALTER USER &username IDENTIFIED BY VALUES '&password_hash';
    SHOW USER
    UNDEFINE username
    UNDEFINE password_hash
    UNDEFINE hostname
    UNDEFINE servicename
    UNDEFINE listenerport
    WHENEVER SQLERROR CONTINUE
    SET VERIFY ONAnd by so doing you just kicked the user's password expiration on down the road, negating the benefit of havng a password expiration.
    Also, you locked out the legitimate user of this account, until such time as you reset it back to the original. And in the mean time, if this happens to be an account used by some automated process, that process doesn't know the new "temporary" password and runs a risk of locking the account from too many invalid connection attempts. Try to become SYSMAN or DBSNMP from this, and you will very quickly kill OEM.
    This has "bad idea" written all over it. What problem is it supposed to be be solving?

  • Port number from 7777 to 8080 - URGENT please

    dear all,
    i'm using Apex 2.2,
    i wanted to change port number from 7777 to 8080,
    due to Security Reasons, i have to change the port from 7777 to 8080
    in which File i need to do the Changes & what are the Steps to be Followes,
    http://10.33.20.6:7777/pls/apex1/apex
    i wanted to change the same to
    http://10.33.20.6:8080/pls/apex1/apex
    please Help me out in this,
    its is Very URGENT PLEASE
    Many thanks

    This is unlikely to be any help becaue your URL specified 'pls' in the path indicating that you are using mod_plsql, but but you might like to check that you are not inadvertently servicing your Apex instance with the embedded PL/SQL gateway.
    Check to see if you are using EPG with the simple sql :
    SELECT DBMS_XDB.GETHTTPPORT FROM DUAL;
    If value returned is 7777 then you appear to be using EPG.
    Change the port using EXEC DBMS_XDB.SETHTTPPORT(8080);
    And then navigate your http://10.33.20.6:8080/pls/apex
    As I said it's unlikely to be any help but wort checking all the same.

  • Strip port number from request

    We recently upgraded our network and proxy servers. After the upgrade the proxy started adding port number of the origin web server to the request.
    For example www.xxx.com became www.xxx.com:85 if backend web server was listening to alteon on port 85.
    The response from the web server is keeping the port number. We would like to strip the port number off. www.xxx.com:85/foo -> www.xxx.com/foo.
    This is only affecting us adversely in 301 and 302 redirects where we have to give new url to client
    Message was edited by:
    mshamber001

    Ideally, the reverse proxy should be configured to correctly rewrite URLs for the servers it's reverse proxying. (For example, Sun Java System Web Server Proxy 4.0 can be used as a caching reverse proxy and load balancer. It will automatically rewrite the URLs used in 301 and 302 redirects.)
    If for some reason it's not possible to configure the reverse proxy correctly, you can tell Web Server 7.0 which port to use in redirects using the <server-name> element in server.xml:<server-name>www.example.com:80</server-name>If you're using Web Server 6.1 (SP2 or higher), you must instead use the servername attribute in server.xml:<LS ... servername="www.example.com:80" />

  • Getting host name and port number from application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • Getting host name and port number from an application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • Sharepoint 2010 appended port number in the public URL when redirect

    I'm new in sharepoint so please bear with me.
    We have a sharepoint deployment that has 4 WFEs, each WFE has 4 sites, all on a different port number.  For example;
    Site 1: http://site1.server1:11111
    Site 2: http://site1.server1:22222
    Site 3: http://site1.server1:33333
    Site 4: http://site1.server1:44444
    We have a load balancer that use a public URL to all these sites.  For example;
    Site 1: http://site1
    Site 2: http://site2
    Site 3: http://site3
    Site 4: http://site4
    Here is the problem.  Some of the link in the sharepoint site, when click, the URL is appended with the port number at the end of the public URL.  For example, http://site1:11111.
    I tried playing around with the AAM but it doesnt yield anything.  Any advise from the expert would be appreciated.

    Hi,
    Look at your default AAM.  This controls how the URL is appended or not.  You also need to look at the site bindings in IIS and make sure you have them for each site, for port 80.  And you need an alternate access mapping that routes site.server:Port
    to site if your desired outcome is to have any load balanced call route back to the default alternate access mapping of http://site1
    you would have a binding on http://site1 on port 80 in iis, and a host header associated with this site.
    Also, if you are using path based sites, this will only work for one site.  You can tell if you're using path based site collections if you see a / in front of their names inside view all site collections.
    Microsoft recommends using Host named site collections, check out this technet
    http://technet.microsoft.com/en-us/library/cc424952(v=office.15).aspx
    Stacy www.sharepointpapa.com

  • 10g express, how to change port number for the database home page

    10g express uses port 8080 for its http listener. However this number has been used by Tomcat on my computer. How can I chang the port number for the 10g home page?
    Regards
    jl

    Andy, thank you very much, I have been able to changed the port number following your advice.
    I hope you do not mind I ask a further questions along this line:
    I installed 10 express db on 2 computers. One with Tomcat and the other without. Following your advice, I successfully changed the port number on the one without Tomcat.
    On the one with Tomcat, I believe it was because I installed the 10g express while the Tomcat was running, I can neither go to the 10g's home page (page cannot be displyed), nor logon to the database from sqlplus (ora-12560: TNS:protocal error) even after I shut down the Tomcat. By checking with 'netstat -an', it is known that the http listerner is not listerning.
    Can I change some configuration file to solve this problem? Or do I have to reinstall 10 ex? I prefer the 1st aproach of changing config file, even it is not as easy as reinstallation.
    Thanks
    jl

  • Hide Port number in the URL

    I would like to hide the port number, and everything to the right of it, from the URL to my applications.
    For example:
    I would like to have this URL:
    http://myhostname:7777/pls/apex/f?......
    read something like this:
    http://myhostname/CMS
    I dont know if this is something trivial, or not,
    or even if I'm addressing this issue to proper forum.
    Does anyone have any suggestions for me please.
    Thanks- Gary

    I have a very similar question as well. I am very new to web applications and web development in general, but we have some here that will come up by simply typing in the IP of the host or the word associated with that host in our local DNS environment. You are then directed to whatever site is on port 80 of that host.
    I would like to do the same with my app I have built in App Express - have users type in a "keyword" and they are immediately directed to my application home page. If my application URL requires a specified port 8080, this doesnt happen by simply pointing to the host. Is it as simple as changing the port number for the application?

  • How to get page number from the PDF using Javascript

    Hi,
    We are having list of Single page PDF. The pdf are named in the order,
    ISBN_Author_01.PDF  (with real page number as i)
    ISBN_Author_02.PDF  (with real page number as ii)
    ISBN_Author_03.PDF  (with real page number as iii)
    ISBN_Author_04.PDF  (with real page number as 1)
    ISBN_Author_05.PDF  (with real page number as 2)
    ISBN_Author_06.PDF  (with real page number as 3)
    ISBN_Author_nn.PDF  (with real page number as 500)
    Here each pdf has a page number and in sequential order.
    The task is to check whether all the pdfs are in sequential order (i.e i, ii, iii, 1, 2, 3). If any page is missing, the script should throw an error report.
    To do this task, I am writing a Javascript to get the real page number from the PDF.
    Can anybody help me how to get the page number from the PDF using Javascript.
    Thanks,
    Gopal

    The "real" page number within a PDF is the count of the physical page starting at 0, zero.
    pageNum numPages
    The number printed on each page is the page label.
    setPageLabels  getPageLabel
    You will have to open each PDF and your script would need to know the page label for that file. I would expect you would need to build a 2 dimensional  array of the file names and the page label for the page within that array.

  • Hi. I've changed my hard drive on my macbook pro and wanted to reinstall logic pro but although I took the serial number from the "about" box it rejects it when I try to reinstall. It was an upgrade to Logic 8 originally. What can I do? Urgent!

    Hello. I have installed a new hard drive on my Macbook Pro with OSX Tiger. I tried to reinstall Logic 8 Pro but it refuses the serial number when I try to install it. I took the serial number from the "About" box when Logic was still installed but no good. The software was originally an upgrade, and I don't think I have the disks for the previous version. What do I do? This is important because I only use the computer for music. Thank you.

    There's actually an even simpler solution that doesn't include buying a new version of Logic.  He can use his original version easily.  Of course, that depends if the OP knows how to effectively use his computer though...

  • How can I remove the page number from the first page of the document that is the cover page?

    How can I remove the page number from the first page of the document that is the cover page?

    If you open the Pages panel, (Window>Pages) you will see thumbnails of your master pages and your document pages. In new documents, there is usually a master called A-Master and one called None. If you drag the thumbnail of the None master onto the thumbnail of a document page, it will apply that master to that page. Presumably, you have made your page numbers on A-Master, so this will usually do the trick. If you have elements on A-Master that you need on the first page, but just not the page number, you can duplicate A-Master (which, by default will give you B-Master, but you can change the names if you like) and remove the page number on the duplicate and apply that to the document page.
    It might also be worth noting that you can apply master pages in the fly-out of the Pages panel. Go to the fly-out triangle and go down to Apply Master to Pages…, then select a master to apply and the range of pages (1-8 will give you all 8, 1, 3, 5, 7 will be the odds, 1-3, 4, 6-8 if you want continuous ranges and individual pages).

Maybe you are looking for

  • Bug: lost selection after a mouse drag

    To reproduce: - select many entities in a diagram - move them a bit via mouse drag what happens - the group loses focus. If you've been unfortunate, you've selected non-contiguous entities (via CTRL-click over) and now they are somewhere in the diagr

  • ORACLE RAC 11G Certification

    Hi , I have completed my OCP 10G certification still training is left in this ... Please help me to suggest I wish to move forword for doing RAC specilization certification . Please help me to guide and proposed me how sud move forward for the perper

  • SolMan 7.1 Alerts to SNMP traps

    Hi all, We will start the process of implement SolMan 7.1 and with this we will migrate all the alerting that we have in SolMan/CCMS 7.0 using CCMS autoreactions methods to the new Alert infrastructre provided in SolMan 7.1. It is my understanding th

  • SSD Drive in Macbook Pro for Live PA

    Hi all Just wondered if there are any people on here who have experience with a SSD Drive in their Macbook Pro using it in Live PA situations? I'm trying to make it shock/vibration resistant (well as far as possible) and reduce heat. There are some r

  • Connecting Flight Demo not work

    Hi, all I configed the multi-booking flight demo according to the Guide. After I executed the sample, I can't see any error from the SXMB_MONI except 'Outbound Status' column is a red flag. The page showing 'Flight booking order sent. Awaiting confir