2
votes
Vote UpVote

Checking if a TCP port is Open using Delphi and Winsocks

The Road to Delphi – Many times we need to know if a TCP port is open or not, here I leave a function to perform this task using winsoks. Code tested in Delphi 7, 2007 and 2010. uses Winsock; function PortTCP_IsOpen(dwPort : Word; ipAddressStr:AnsiString) : boolean; var client : sockaddr_in; sock : Integer; ret : Integer; wsdata : WSAData; begin Result:=False; ret := WSAStartup($0002, wsdata); //initiates use of the Winsock DLL if ret<>0 then exit; try client.sin_family := AF_INET; //Set the protocol to use , in this case (IPv4) client.sin_port := htons(dwPort); ...
Favorite? Off-Topic? Rodrigo @ 2010-02-21 08:33

Statistics

Visits: 775
Votes: 2
Favorites: 1
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Jan Derk
kanenberg
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)