development-point

development-point (https://vb.development-point.com/index.php)
-   الأرشيف (https://vb.development-point.com/forumdisplay.php?f=80)
-   -   وتستمر البرمجة الحصرية لعيون المطورين .. شرح برمجة برنامج يفحص لك البورت .. (https://vb.development-point.com/showthread.php?t=1767)

‏windows 8 11-03-2012 05:15 PM

وتستمر البرمجة الحصرية لعيون المطورين .. شرح برمجة برنامج يفحص لك البورت ..
 


أخواني اقدم اليوم لكم دالة تمكنك من فحص البورت ..

اتفضلوا :

http://im18.gulfup.com/xHnD2.png
اقتباس:
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);
//convert to TCP/IP network byte order (big-endian)
client.sin_addr.s_addr := inet_addr(PAnsiChar(ipAddressStr));
//convert to IN_ADDR structure
sock := socket(AF_INET, SOCK_STREAM, 0); //creates a socket
Result := connect(sock, client, SizeOf(client)) = 0;
//establishes a connection to a specified socket
finally
WSACleanup;
end;
end;

http://im18.gulfup.com/xHnD2.png
اقتباس:
الان التنفيذ :

if PortTCP_IsOpen( 81, '192.168.1.1') then
ShowMessage('Open')
else
ShowMessage('Not Open');

http://im18.gulfup.com/xHnD2.png
نضع هذا الكود في الزر ..

في حال كان البورت مفتوح على الايبي

التالي : 192.168.1.1
يظهر لك رسالة OPEN
غير ذلك يظهر رسالة على انه مغلق . .

أتمنى أن تطوروا هذا الكود .. وان يفيدكم في ما يحبه الله ويرضاه ..


والسلام عليكم ورحمة الله وبركاته


http://www.sqebd.com/vb/images/smili...20%2869%29.gifhttp://www.sqebd.com/vb/images/smili...20%2869%29.gif



الساعة الآن 10:43 PM

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
development-point

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47