How to make an iPhunter with Delphi (IP hunter of Swordsman)

zhaozj2021-02-08  270

Some people say that the current programmer has become an assembled worker. It is actually very reasonable. It can be implemented using the control module small code. Delphi 5.0 provides a wealth of Internet controls, using the TCP / IP client-server to solve the problem. The key control is Serversocket, we imitate the interface of the iPhunter with a Button1 (button), a ComboBox1 (for display), which can start writing code on a blank form. First, this ComboBoX1 must be able to display multiple IPs, we set a variable y to accumulate ComboBox1.Items [Y], var Y: integer; our idea is as follows, when Serversocket active PORT (port) receives a TCP / IP protocol When the connection request, return the IP value of the other party and pass it to ComboBox. The activation of ServerSocket by Button1 is turned on. We added the code procedure TForm1.ServerSocket11ClientConnect (Sender: TObject; Socket: TCustomWinSocket); in the ServerSocket On ClientConnect events begin combobox1.Items.Insert (y, ''); // adding an empty record combobox1.Items [y] : = Socket.RemoteadDress; // Get the other party's ip Label1.text: = 'Capture' INTSTOSTR (Y 1) 'IP'; // Use a label to display a total of IP Y: = Y 1; // Counting variable plus 1 socket.close; end; now, set the button's CAPTION property to 'start', add the following code in its click event Procedure TFORM1.SPEEDBUTTON7CLICK (Sender: TOBJECT); Begin IF SpeedButton7.caption = 'Start' TEN BEGIN ServerSocket11.port: = 80; // This sentence can be set in the ServerSocket property, capture the connection serversocket11.active: = true; // activation port SpeedButton7.caption: = ' Stop '; END ELSE BEGIN ServerSocket11.Active: = false; // Close Port SpeedButton7.caption: =' Start '; ComboBox1.Clear; // End Capture, Empty History Information Y: = 0; // Counting Variable Reset End; END;

转载请注明原文地址:https://www.9cbs.com/read-1375.html

New Post(0)