На, так пойдет
Add(MainForm,2953706,154,112)
{
Width=273
Height=113
Position=1
}
Add(Edit,835315,196,112)
{
Left=10
Top=10
Width=125
Text="127.0.0.1"
Alignment=1
}
Add(Edit,4363003,245,112)
{
Left=140
Top=10
Width=75
Text="80"
Alignment=1
}
Add(Button,13770907,154,182)
{
Left=85
Top=45
Width=95
TabOrder=-1
Caption="IsOpen"
link(onClick,2868222:doPortTCPIsOpen,[])
}
Add(InlineCode,2868222,217,182)
{
WorkPoints=#15:doPortTCPIsOpen|
EventPoints=#8:onResult|
DataPoints=#2:IP|4:Port|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|39:uses kol,Share,Debug, Windows, Winsock;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|35: IP, Port, onResult: THI_Event;|60: procedure doPortTCPIsOpen(var _Data:TData; Index:word);|5: end;|0:|14:implementation|0:|74:function PortTCP_IsOpen(dwPort : Word; ipAddressStr:AnsiString) : boolean;|3:var|23: client : sockaddr_in;|19: sock : Integer;|1: |19: ret : Integer;|19: wsdata : WSAData;|14: begin|15: Result:=False;|69: ret := WSAStartup($0002, wsdata); //initiates use of the Winsock DLL|22: if ret<>0 then exit;|5: try|87: client.sin_family := AF_INET; //Set the protocol to use , in this case (IPv4)|96: client.sin_port := htons(dwPort); //convert to TCP/IP network byte order (big-endian)|97: client.sin_addr.s_addr := inet_addr(PAnsiChar(ipAddressStr)); //convert to IN_ADDR structure|66: sock :=socket(AF_INET, SOCK_STREAM, 0); //creates a socket|100: Result:=connect(sock,client,SizeOf(client))=0; //establishes a connection to a specified socket|9: finally|13: WSACleanup;|6: end;|4:end;|0:|67:procedure THiAsmClass.doPortTCPIsOpen(var _Data:TData; Index:word);|5:begin|86: _hi_onEvent(onResult, ord(PortTCP_IsOpen(ToIntegerEvent(Port), ToStringEvent(IP))));|4:end;|0:|4:end.|
link(onResult,6394217:doEvent,[])
link(IP,835315:Text,[(223,163)(202,163)])
link(Port,4363003:Text,[(230,163)(251,163)])
}
Add(LED,10516296,336,175)
{
Left=225
Top=5
}
Add(IndexToChanel,6394217,273,182)
{
link(onEvent1,10516296:doOff,[])
link(onEvent2,10516296:doOn,[])
}