Re: socks5 verbindung testen
10. Nov 2009, 21:45
Versuchs mit folgendem Code.
[delphi]
uses
.., winsock;
function CanListen(Port: DWORD): Boolean;
var
Name : TSockAddr;
nRet : Integer;
Socket : TSocket;
WSData : TWSAData;
begin
result := False;
WSAStartup($0101, WSData);
try
Socket := WinSock.Socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
try
if Socket<>INVALID_SOCKET then begin
ZeroMemory(@Name,SizeOf(TSockAddr));
with Name do begin
sin_Family := PF_INET;
sin_Port := htons(Port);
sin_Addr := TInAddr(htonl(INADDR_ANY));
end;
nRet := Bind(Socket, Name, SizeOf(Name));
if (nRet <> SOCKET_ERROR) then
result := (WinSock.Listen(Socket,SOMAXCONN) <> SOCKET_ERROR);
end;
finally
if Socket <> INVALID_SOCKET then
CloseSocket(Socket);
end;
finally
WSACleanup;
end;
end;
|