TCP plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
 
m (→‎Links: use <attach> to include a link to an uploaded zip)
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
== Links ==
== Links ==


Download v1.0:<br>
Download v1.0: [http://www.rejment.com/TCP.zip TCP.zip]
<attach>TCP.zip</attach>
 
Download v1.0 UNICODE build: <attach>NSIS TCP Plugin Unicode x86.zip</attach>


== Description ==
== Description ==
I made this little plugin to be able to check for TCP ports that our server software can use.
I made this little plugin to be able to check for TCP ports that our server software can use.
There is currently only one function that checks if a port is already in use or not, but it is useful.
There is currently only one function that checks if a port is already in use or not, but it is useful.<br>
 
Created by Daniel Rejment.
== Usage ==
Drop the dll into the Plugins folder of your NSIS installation.
 
Call TCP::CheckPort "12345"
 
Return value on the stack is:
 
"free" - if the port is free for binding
 
"inuse" - if the port is already in use
 
"socket_error" - if the port string is not between 1 and 65535


== Sample Usage ==
<highlight-nsis>
validate_port:
  TCP::CheckPort $1
  Pop $0
  StrCmp $0 "free" port_ok
  StrCmp $0 "socket_error" socket_error
  StrCmp $0 "inuse" socket_inuse
  Goto port_ok
socket_inuse:
  MessageBox MB_OK "The Port is in use by another application."
  Abort
socket_error:
  MessageBox MB_OK "Invalid TCP Port number. It should be an integer between 1 and 65535."
  Abort
port_ok:
</highlight-nsis>




[[Category:Plugins]]
[[Category:Plugins]]

Latest revision as of 17:01, 27 January 2016

Author: daniel.rejment (talk, contrib)


Links

Download v1.0: TCP.zip

Download v1.0 UNICODE build: NSIS TCP Plugin Unicode x86.zip (35 KB)

Description

I made this little plugin to be able to check for TCP ports that our server software can use. There is currently only one function that checks if a port is already in use or not, but it is useful.
Created by Daniel Rejment.

Sample Usage

validate_port:
  TCP::CheckPort $1
  Pop $0
  StrCmp $0 "free" port_ok
  StrCmp $0 "socket_error" socket_error
  StrCmp $0 "inuse" socket_inuse
  Goto port_ok
socket_inuse:
  MessageBox MB_OK "The Port is in use by another application."
  Abort
socket_error:
  MessageBox MB_OK "Invalid TCP Port number. It should be an integer between 1 and 65535."
  Abort
port_ok: