Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Check if Port is open (http://forums.winamp.com/showthread.php?t=388574)

pkonduru 12th January 2016 22:57

Check if Port is open
 
Hi All,

I am trying to use this in my installer to see if a port is open. I need to show a message box if the port cannot be used or proceed if its ok to use the port.

http://nsis.sourceforge.net/Check_open_ports

I am not able to figure out the example in this page. If I used the condition with {If}, how would this be:

${If} ${TCPPortOpen} $PortNumber
MessageBox MB_OK|MB_ICONSTOP "$PortNumber is already using by another program..."
Abort
${Else}
MessageBox MB_OK"$PortNumber is open to use"

Is this correct?

Anders 12th January 2016 23:27

Looks OK to me. What happens when you run your installer?

pkonduru 13th January 2016 00:09

The installation proceeds no matter what port I give. Is there any port on my Windows machine I can specify where this check will fail and abort?

JasonFriday13 13th January 2016 03:46

There should be an ${EndIf} at the end of that code. Do you get any warnings when you compile the script?

pkonduru 13th January 2016 18:09

Hi Jason,

Yes I do have a ${EndIf}, didnt post the whole snippet, here it is:


${If} ${TCPPortOpen} $PortNumber
MessageBox MB_OK|MB_ICONSTOP "$PortNumber is already using by another program..."
Abort
${Else}
MessageBox MB_OK "$PortNumber is open to use"
${EndIf}

what I don't get is , if the Port is open as per this line below,

${If} ${TCPPortOpen} $PortNumber

Doesn't this mean that the port is OK to use and proceed with the install?

Anders 13th January 2016 21:11

Open probably means some application is using it. I don't understand how this can be so hard to test, since you are checking for ports I assume you have some application that opens a port so you can just run it and test your installer. You can also use netstat or download TCPView to find open ports on your machine...

pkonduru 14th January 2016 21:32

Thanks Anders. My understanding was "TCPPortOpen" meant an "Open" port which one could use, sorry for the confusion. I did verify that the code is working by entering a port which was in use by the application.

Thank you everyone for the inputs.


All times are GMT. The time now is 18:01.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.