hab hier was für euch blindgänger
nur zur info: ungetestete codes sind unerwünscht vor allem wennse hinten und vorn ned stimmen
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE}
uses
winsock,windows,
SysUtils;
function GetInAddr(host: string):TInAddr;
var h : PHostEnt;
begin
result := TInAddr(inet_addr(pchar(host)));
if integer(result) = INADDR_NONE then begin
h := GetHostByName(pchar(host));
if h <> nil then begin
cardinal(result) := pcardinal(h^.h_addr_list^)^;
end
else
cardinal(result) := 0;
end;
end;
function CheckPortOpen(ip_or_host:string;port:word):boolean;
var
sock: TSocket;
HostAddr: TSockAddrIn;
begin
with PSockAddrIn(@HostAddr)^ do begin
sin_family := AF_INET;
sin_port := htons(port);
sin_addr := GetInAddr(ip_or_host);
end;
sock := socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
result := connect(sock,HostAddr,sizeof(HostAddr)) <> SOCKET_ERROR;
closesocket(sock);
end;
var WSAData: TWSAData;
begin
writeln('all code (C) retnyg, tha almighty');
WSAStartup($0101,WSAData);
if checkportopen('127.0.0.1',110) then writeln('port open') else writeln('not');
WSACleanUp;
readln
end.