The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Check for Listening TCP Port
Posted by: Shadowdane | October 23, 2010 @ 12:34pm
VB.NET Code
[
Download
]
' Check if Server Port is available Dim isPortAvailable As Boolean = True Dim ipGlobalProp As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties() Dim ipEndPt() As IPEndPoint = ipGlobalProp.GetActiveTcpListeners For Each tcpListeners As IPEndPoint In ipEndPt If tcpListeners.Port = ServerPort Then isPortAvailable = False Exit For End If Next If isPortAvailable = False Then ' Connection already open on Server Port InvokeUpdateServerStatus("[ERROR] Connection Already Open on TCP Port: " & ServerPort) Else ' Enable Start Server Button InvokeButtonStartServer(True) InvokeUpdateServerStatus("[INFO] Server Ready to Start...") End If
Syntax Highlighting
[
Open in new window
]
Author Comments
The "ServerPort" variable is global and reads the tcp port number from a configuration file. I didn't think it was necessary to include the code where the config file is read.
Rating
4.43 / 8
90 Votes
http://codebin.yi.org/908
page generated in 0.00 seconds