Autor Beitrag
zCoRp
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Sa 08.10.05 15:55 
Ich frag mich grad echt was ich falsch mach...
Hab mal angefangen nach vielen anderen Progs mal was mit Sockets zu schreiben...
Ich will nen bestimmten Port Scanner entwickeln und dafür will ich halt mal nen laufenden ErstCode hinbekommen...

hier hab ich ma was geschrieben:
ausblenden volle Höhe Delphi-Quelltext
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:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
program ru_scan;

{$APPTYPE CONSOLE}

uses
  Windows,
  Messages,
  SysUtils,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  StdCtrls,
  ScktComp;

var
  port_to_scan: integer;
  maxport: integer;
  WSsocket: TClientSocket;
  IsRunning: Boolean;
  ip: string;

Procedure WSsocketError(Sender: TObject; Socket: TCustomWinSocket;
 ErrorEvent: TErrorEvent);
Begin
  //connection failed....
  writeln('Port: ' + inttostr(Port_to_scan) + ' - Closed.');

  wsSocket.Active := False; //close it
End;

Procedure WSsocketConnect(Sender: TObject; Socket: TCustomWinSocket);
Begin
  //socket connection made
  //port must be open!
 writeln('PORT: ' + inttostr(port_to_scan) + '; OPEN!');

 wsSocket.Active := False;
End;

begin
  ip := '217.110.104.156';
  port_to_scan := 80;
  wsSocket.Address := ip;
  wsSocket.Port := port_to_scan;
  wsSocket.Active := True;
  (*if (wsSocket.Socket.Connected = TRUE) then
    begin
    writeln('PORT: ' + inttostr(port_to_scan) + '; OPEN!');
    end else begin
    writeln('Port: ' + inttostr(Port_to_scan) + ' - Closed.');
    end;
  *)


  read;
end.


Nur leider kommt da immer nen wahrloser Error und ich kann den FEhler nicht finden...
Compilieren geht ja ohne probs... kann mir jemand bitte helfen?

Wär echt toll, danke, Marco
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 08.10.05 16:42 
Du musst den ClientSocket erst Erstellen.
ausblenden Delphi-Quelltext
1:
WSocket:=TClientSocket.Create;					


P.S.: Ich wette, es war eine EAccessViolation-Fehlermeldung.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
zCoRp Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Sa 08.10.05 18:09 
oh mein gott wie dumm ich war.... danke :)
zCoRp Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: So 09.10.05 13:00 
Joa gut ich bin zwar weiter... aber der zeigt mir jeden Port bei jeder IP als Closed an... wieso? der Port und IP im beispiel sind z.b. offen... bzw waren es bei mir falls er jetzt nichtmehr sein sollte...

ausblenden volle Höhe Delphi-Quelltext
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:
program ru_scan;

{$APPTYPE CONSOLE}

uses
  Windows,
  Messages,
  SysUtils,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  StdCtrls,
  ScktComp;

var
  port_to_scan: integer;
  maxport: integer;
  WSsocket: TClientSocket;
  IsRunning: Boolean;
  ip: string;

begin
  Wssocket:=TClientSocket.Create(nil);
  ip := '195.4.43.5';
  port_to_scan := 21;
  wsSocket.Address := ip;
  wsSocket.Port := port_to_scan;
  wsSocket.Active := TRUE;
  if (wsSocket.Active = TRUE) then
    begin
    writeln('PORT: ' + inttostr(port_to_scan) + '; OPEN!');
    end else begin
    writeln('Port: ' + inttostr(Port_to_scan) + ' - Closed.');
    end;
  wsSocket.Active := FALSE;

  readln;
end.


Woran kann das liegen? Falsche Abfrage? oder Irgendwas beim connecten vergessen?
Sorry bin halt Neuling mit dem Socket Programmieren...
zCoRp Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mo 10.10.05 13:23 
hat sich erledigt danke