Other ways to check for used port

Hi,
I have this code to check for used port :
try {
ServerSocket s = ServerSocketFactory.getDefault().createServerSocket(port);
s.close();
} catch (Throwable e1) {
InstallLogger.instance().info("Unable to open port " + port + ".\n" + e1.getMessage());
return false;
The code works fine. But in Windows 2003, it behaves differently. It does not detect that a "tomcat shutdown port" is already in use. Any other used port throws an exception, which is what is expected. Any idea will be appreciated. Thanks!

below code loops till it gets a open port
     private int port = 2562;
     public void checkPort() {
          try {
               ServerSocket sock = new ServerSocket(port);
               sock.close();
               System.out.println(port + " port is open");
          }catch(BindException b) {
               System.out.println(port + " port is not available");
               port++;
               checkPort();//will check till it gets a open port.
          catch (IOException e) {
               //do other validations
     }

Similar Messages

  • Any way to check for errors in an external table besides the log?

    For example if you have an external table where a column is defined with a CHAR(1) but when you run a SELECT on it, the mapping comes up with trying to put a CHAR(2) into that single space. The only way I'm aware to see if something is wrong is to check the .log file. Is there any other way to check for an error message or count?
    I'm mounting external tables and copying data over to a 'holding' table to be able to work on the data before it's moved into the actual production table with PL/SQ code. If the stored proc can determine what rows are bad or missing or even that there just are some rows with problems then hand back to the app, it would greatly improve things.
    Thanks.

    No other way than to check for the existance of a .bad file, then have a look see at the .log then?

  • Is there any other ways to check whether is my phone faulty or my sim card issue. I can only use it for call, my network to 3G or 4G suddenly cannot use.

    Is there any other ways to check whether is my phone faulty or my sim card issue. I can only use it for call, my network to 3G or 4G suddenly cannot use. This happen since yesterday, suddenly can use but suddenly cut off. Called Telco and they reset account but still same.

    See this
    http://support.apple.com/kb/TS4148

  • What is the easiest way to check for internet connection in C#?

    Hi!
    I searched a lot but I didn't get my answer. I'm looking for the easiest way to check for internet connection. Can you help me?
    Thanks a lot.

    Hi Pouya Ebrahimzadeh,
    I suggest you could connect a site to check if it can be opened.
    Public Shared Function CheckForInternetConnection() As Boolean
    Try
    Using client = New WebClient()
    Using stream = client.OpenRead("https://msdn.microsoft.com/")
    Return True
    End Using
    End Using
    Catch
    Return False
    End Try
    End Function
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • C6380 Printer's always running out of ink. Is there a way to check printer use history?

    c6380 printer always seem to run out of ink. Is there any way to check printer use history. No one owns up to using it much, but we also seem to run through paper. Maybe the pets are secretly using it?

    Hi - This may not be exactly what you're looking for but the Extended Self-Test page does provide a page count.  It doesn't give you a history of when pages were printed, but it will at least tell you have many pages have been printed overall.
    Hope that helps.
    Kevin
    Say Thanks by clicking the Kudos thumbs up. Please mark the post that solves your problem as an Accepted Solution so other forum users can utilize the solution.
    I am an HP employee.

  • Best Way to Check for same Word in string?

    If I have an array of words, would the best way to check for the same word be to use 2 for loops?

    Huh?
    Sounds like homework...
    What is a word? Presumably a String.
    For equality of Strings you use...
        String s1 = ....
        String s2 =....
        if (s1 == s2) { equal depending on null case
        else if ((s1 != null) && (s1.equals(s2))) { equal }
    For the case of checking one array to another....
          while items in array1
                 get itema from array1
                      while items in array2
                           get itemb array2
                                  is itemb equal (see above) to itema
                                         yes - then do something

  • My MacBook Pro is suddenly slower...is there an easy way to check for viruses?

    My MacBook Pro is suddenly slower...is there an easy way to check for viruses?

    OpsMgr have methods which can get all host classes. Here my own function which can solve your issue:
    function Get-SCOMClassProperty {
    param(
    [Microsoft.EnterpriseManagement.Configuration.ManagementPackClass]
    [Parameter(Mandatory = $true)]
    $ManagementClass,
    [Switch]
    [Parameter(Mandatory = $false)]
    $KeyOnly
    function Get-SCOMClassKeyProperty {
    param(
    $ManagementClass
    $ManagementClass.PropertyCollection | ? {$_.Key}
    If ($ManagementClass.Hosted) {
    Get-SCOMClassKeyProperty -ManagementClass $ManagementClass.FindHostClass()
    If ($ManagementClass.Base) {
    Get-SCOMClassKeyProperty -ManagementClass (Get-SCOMClass $ManagementClass.Base.Id)
    function Get-SCOMClassAllProperty {
    param(
    $ManagementClass
    $ManagementClass.PropertyCollection
    If ($ManagementClass.Base) {
    Get-SCOMClassAllProperty -ManagementClass (Get-SCOMClass $ManagementClass.Base.Id)
    $ManagementClassProperty = Get-SCOMClassKeyProperty -ManagementClass $ManagementClass
    If (!$KeyOnly) {
    $ManagementClassProperty += Get-SCOMClassAllProperty -ManagementClass $ManagementClass
    $ManagementClassProperty | Select-Object -Unique
    If you need to do it in SCOM 2007 R2 then you can try my scripts from this examples http://systemcenter4all.wordpress.com/2013/05/15/scom-monitoringclass-functions/. Last should work in 2007 R2 and in 2012. Example in thread will work only in 2012.
    For example just run command:
    New-SCOMManagementGroupConnection
    $ManagementClassName = "Microsoft.SQLServer.Database"
    $ManagementClass = Get-SCOMClass -Name $ManagementClassName
    Get-SCOMClassProperty -ManagementClass $ManagementClass -KeyOnly | select Name
    Vladimir Zelenov | http://systemcenter4all.wordpress.com

  • What is the best way to export for use on internet?

    what is the best way to export for use on internet?

    It depends. Is this for a personal web site or for a site like YouTube, Vimeo or Facebook?
    For YouTube, Vimeo and Facebook, use Publish & Share/Computer/AVCHD using one of the YouTube presets.

  • My iphone was stolen, when i tracked my phone its already offline so without hesitation i deleted it. Is there any other way to track it using serial number? or make the phone good as a dead iphone?

    my iphone was stolen, when i tracked my phone its already offline so without hesitation i deleted it. Is there any other way to track it using serial number? or make the phone good as a dead iphone?

    Sorry, there is no way to track your phone. Call your carrier, & if they offer blacklisting, have them blacklist your phone.
    Since you're running iOS 7.0. the phone is useless to anyone but you, as it cannot be re-activated without knowing your Apple ID/Password.

  • Checking for FireWire port trouble

    Hello,
    I've got an iMac G3 running OS 10.4.11 and would like to know if there is a way to check the status of the 2 FireWire ports without the external DVD drive that was used to install OS X. The drive stopped working and has been sent for repair and/or replacement. Any help would be greatly appreciated.

    Do you want to confirm that the FireWire bus/port is operating correctly and that it's not the cause of the external DVD drive's failure? Obviously, another FireWire device would provide the answer, since you're not going to be able to check the FireWire controller chip on the motherboard.

  • TCode for used ports information

    Hi,
          Is there any TCode to find out the used ports by SAP like (MSG Server, Gateway, etc... (except SMICM)) from R/3 level??
          Your help much appreciated.
    Regards,
    Gaurav

    Hi,
    You are correct. There is no transaction, program or otherwise available at the SAP level that will give you this information. So you will have to go to the OS level.
    You can use the system tool "netstat" can be used to check which port is already in use. The program returns the ports currently used by the computer. For example, if "netstat -a   grep sapdp53" returns an output, port sapdp53(3253) is in use.                                                                               
    Unfortunately, it is not possible to use the "netstat" program to determine which application is using a port. There is a tool for Unix "Isof" (LiSt Open Files)  on the FTP Server "ftp://vic.cc.purdue.edu/pub/tools/unix/lsof", which you can use to determine this. For more information, see also   
    the readme:
    ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/README and the developer's license conditions.  
    Hope this helps
    Michael

  • Check for used DCs failed:Cannot build because used component is broken

    Hi All,
    when i Build the DC after creation public part getting the below error,
    Jun 30, 2008 4:06:41 PM /userOut/Development Component (com.sap.ide.eclipse.component.provider.listener.DevConfListener) [Thread[ModalContext,5,main]] ERROR: eprtest: Build failed for chdp.com/eprtest(MyComponents) in variant "default": Cannot build because used component is broken: chdp.com/labourmanagement( MyComponents)
    please help me.
    Thanks,
    RameshBabu.V

    Hi rameshbabu,
                             Check for the dc chdp.com/labourmanagement , which u r using as dependency for ur dc . That dc is not built properly. Rectify the problem in chdp.com/labourmanagement & then rebuild ur dc, which is using that dc as used dc.It will work properly.
    regards
    Sumit

  • What's the best/fastest way to check for existance of a userobject

    We are developing an Addon in VB.NET.
    I think there are two ways to check if a table exists:
    1) usertableMD.GetByKey(tablename)
    2) orecordset.DoQuery("SELECT * FROM sysobjects WHERE ...)
    I would like to use the first way, but is the GetByKey fast and how much will the call "System.Runtime.InteropServices.Marshal.ReleaseComObject(usertableMD) " slow down ?

    I personnaly use GetByKey
    I think that opening a recordset is not the optimized SAP solution, and anyway, you'll have to release the recordset
    Private Function UserTableExists(pst_TableName) As Boolean
        Dim dsa_UserTablesMD As UserTablesMD
        Dim dbo_ReturnCode As Boolean
        dsa_UserTablesMD = msa_Company.GetBusinessObject(BoObjectTypes.oUserTables)
        dbo_ReturnCode = dsa_UserTablesMD.GetByKey(pst_TableName)
        System.Runtime.InteropServices.Marshal.ReleaseComObject(dsa_UserTablesMD)
        Return dbo_ReturnCode
    End Function

  • Other ways to authenticate for iBooks account withouten creditcard?

    I Was writing a mini ebook for iBooks. I spended very much time in it, but when i clicked publish, it promted me to make an ibooks account, and sayed it required a credit card. Are there other ways to authenticate? Or can i do requests/suggestions/feedback? Thank you for reading and hopefully answering. More details coming. Typed with my iPod touch 4.

    I suggest that you start all over again, using Setup Assistant after restoring the new iMac to factory original conditions, & migrate only the user account(s) you want to keep on it from any older Macs you have.
    There are several good reasons Setup/Migration Assistant will not do what you want:
    1. It is undesirable for privacy & security reasons -- there would be no point in having separate user accounts protected by passwords if someone could use the utility simply to copy whatever they wanted from another user's account into their own. As far as the computer is concerned, each user account is a separate entity, entitled to the same level of privacy & security.
    2. Each user account has its own user preferences, application settings, & so on. There can be several thousand of these items for each user account. There is no way to merge them into one user account, so at best an account merge function would tediously have to ask which of these you wanted retained & which ones you wanted discarded on an item by item basis.
    3. Many popular apps (among them Mail, iTunes, iPhoto, & many browsers) save user data in application-specific master files or databases rather than in individual files. Again, there can be only one of these (at a time) for each user. (For example, while iTunes stores song files individually, user ratings, notes, & other user-specific items are stored in iTunes database files, one per user.) Since each application that does this has its own unique methods & formats, Setup/Migration Assistant would have to know about all of them to somehow merge them into one user account's master or database files, assuming that would even be possible to do without conflicts.
    The tips Pondini provided are the best you can do.
    Message was edited by: R C-R

  • A way to check for doubles in Address Book

    Is there a way or software to check for doubles in Address Book ?
    Thanks

    Address Book>Card>Look for Duplicates.
    hpr3

Maybe you are looking for

  • Why is my page set up drop down different from your illustration in help for printing background

    ''duplicate - https://support.mozilla.com/en-US/questions/830795'' The page set up drop down menu looks nothing like the illustration in help. It does not include a box to check for "print background. How do I print background

  • Can you burn an AVCHD DVD using Premiere Pro 4.1?

    Alright I've been hunting the forums and net for a few hours on this one question. I import my AVCHD video files using Sony Picture Motion Browser for the HDR SR-12 using the full HD setting (1920x1080i) I then pull these into Premiere 4.2.1 and have

  • How to resize a SWF file to fit on stage

    Hi everyone, I'm fairly new to Flash so please bear with me. I'm trying to resize a SWF file made in InDesign. My Flash application is set at 1920x1080 and the SWF file was made at the same size. I need it to be resized to 1700x956. This is the secti

  • Can't Run AFAB - Posting run requested for future period

    Hi, While taking depreciation run for company code in AFAB system is generating the error message "Posting run for future period requested (check entry)" SAP error AA697 Diagnosis There was a check of your entries in the company code and posting peri

  • Freight Units Line item Quantity

    **Hello All,** **We have a requirement to extract the Freight unit line item quantity. Is there a table available in SCM capturing this data. The freight units that we are using in this custom report is Sales orders and Purchase orders.** **Please le