Autor Beitrag
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 02.01.05 17:15 
Ach ja, es fehlt noch das Event "OnClientConnect" beim Server, ich bastle das mal noch rein... Dann wär das doch genau das, was du wolltest, oder Narses???

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 02.01.05 17:16 
WeBsPaCe hat folgendes geschrieben:
Beim VCL-Dingsbums:

So ungefähr der Server:

Was soll das da sein? Ein Server? Der kann/macht ja nix. Ich hatte mir schon vorgestellt, dass das ein vollständiger Code ist, also irgendwas, das auf Client-Anfragen antwortet.

Bisher treten wir auf der Stelle.

cu
Narses

//EDIT: war ich wohl zu langsam... :wink:
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 02.01.05 17:20 
Zitat:
Wie schon gesagt, ich baue grade an nem Webserver. 1000 Zeilen Code. Und die netzcodes sind noch nicht wirklich implimentiert...


ein wenig fehlt da noch...
nochmals das Angebot:
wenn dich mein Ansatz der VCL-Konsole mit parsen und so interessiert, pm
;)
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 02.01.05 17:26 
He Jungs, ich seh' da grad was: Folgende Eigenschaft:

ausblenden Delphi-Quelltext
1:
Srv.Socket.Connected					

ist doch genau das, was ich irgendwo gaaaaaanz am Anfang gesucht hab, die Eigenschaft in der for-Schleife... Wenn ich dort einfach folgendes schreib:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
repeat
Writeln('WAITING FOR CONNECTION...');
Sleep(2000);
until Srv.Socket.Connected;


... geht doch alles so wie ich's will!!!!

Dann fehlt nur noch das mit der Nachricht senden und so... :wink:

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 02.01.05 17:36 
WeBsPaCe hat folgendes geschrieben:
He Jungs, ich seh' da grad was:

Ich kann mich langsam des Eindrucks nicht erwehren, dass das typisch für dich ist... erst schreiben, dann denken... :roll: :wink:

WeBsPaCe hat folgendes geschrieben:
die Eigenschaft in der for-Schleife...

:gruebel:

cu
Narses
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 02.01.05 17:48 
Tja, bin halt ein ganz ein schneller... :D

Nich klar, das mit der Schleife?? Oder hast du dich nur wegen dem for gewundert?? War natürlich ne repeat-until-Schleife...

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 02.01.05 18:18 
was aber immer noch keine lösung für das problem "wie schaffe ich es in der console eine ereignisprozedur zu implementieren" ist...
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 02.01.05 18:22 
problem gelöst, dank google und chinesischen foren:
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:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, forms, ScktComp;

type TCustomSrv = Class(TServerSocket)
     private
     fertig: boolean;
     public

     procedure OCC(Sender: TObject; Socket: TCustomWinSocket);
end;


var  srv : TCustomSrv;

procedure TCustomsrv.OCC(Sender: TObject;
  Socket: TCustomWinSocket);
begin
   writeln('Connected');
   fertig := true;
end;

begin
  application.initialize;
  application.run;
  Srv := TCustomSrv.Create(nil);
  Srv.Port := 2000;
  Srv.OnClientConnect := srv.OCC;
  Srv.Active := True;
  Srv.Open;
  repeat
    Writeln('WAITING FOR CONNECTION...');
    Sleep(2000);                         //<- das sleep könnte problematisch sein
    application.processmessages;
  until srv.fertig
end.
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 02.01.05 18:23 
Applicatio.processMessages wuerde ich weglassen und statdessen nur Sleep(0); machen. afaik ist das Abgeben der Zeitscheibe auch eine Information an das OS, dass der Prozess nicht steht...
und es ist ressourcenschonender...
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 02.01.05 18:34 
aber ohne application.processmessages läufts ned

folgende alternativen (ohne Application Object) wurden auf der chinesischen page www.google.at/search...e+scktcomp&hl=de besprochen:
- ein timer
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TimeProc(Window:HWND; message,idEvent:UINT; dwTime:DWORD);stdcall
begin
......//觸發時所要做的事情
end;

procedure NoWin_Timer;
var TimerID:Integer; Msg:TMsg;
begin
   TimerID:=SetTimer(0,0,1000,@TimerProc);//1000為1000ms觸發一次的意思
   //取得訊息,收到MW_QUIT跳離
   while GetMessage(Msg,0,0,0) do
      DispatchMessage(Msg);//分派Message

   KillTimer(0,TimerID);
end;


- messages abarbeiten lassen
ausblenden Delphi-Quelltext
1:
2:
3:
while start.Server<>nil do
   while GetMessage(Msg,0,0,0) do
      DispatchMessage(Msg);


Msg ist dabei jeweils vom Typ TMsg
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 02.01.05 18:39 
stimmt, ok, man kann keine eingaben machen, daran hatte ich nicht gedacht...
Ich dachte, es ginge einfach nur um das melden, dass der Prozess nicht steht...
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 02.01.05 18:45 
dieser code hier ist übrigens auch sehr intressant: www.google.at/search...e+scktcomp&hl=de
würde man den Server aus diesem link noch mit der Messagebehandlungsroutine von der andren seite verknüpfen, ein paar überflüssige sachen rauslöschen und auf die Unit Forms (also auch das ApplicationObjekt) verzichten, hätte man einen Funktionstüchtigen Console-Open-Source Server für verschiedene Einsatzzwecke...mit geringer dateigrösse.

wer übernimmt das ? :mrgreen:
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 02.01.05 18:49 
das is ja an sich sehr schoen, nur die Kommentare erschliessen sich mir rein inhaltlich nicht... :lol:
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 02.01.05 18:53 
selbst denken oder babelfish.altavista.com bemühen... :gruebel:
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 02.01.05 20:13 
Also, neues Problem:

Clientprog:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, ScktComp, Windows;

var
  Cln: TClientSocket;

begin
  Cln := TClientSocket.Create(nil);
  Cln.Host := '127.0.0.1';
  Cln.Port := 2000;
  Cln.Active := True;
  Cln.Open;
  repeat
  Writeln('CONNECTING...');
  Sleep(2000);
  until Cln.Socket.Connected;
end.


Serverprog:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, ScktComp, Windows;

var
  Srv: TServerSocket;

begin
  Srv := TServerSocket.Create(nil);  
  Srv.Port := 2000;
  Srv.Active := True;
  Srv.Open;
  repeat
  Writeln('WAITING FOR CONNECTION...');
  Sleep(2000);
  until Srv.Socket.ActiveConnections > 0;
end.


Normal müsste doch dann nach dem Connecten beide Programme beenden, oder lieggt das am Sleep??

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 02.01.05 20:33 
ja, liegt am sleep
Das eine Programm (Client) beendet sich sofort nach connect wieder
Und beiM Server is die Connection gleich wieder geschlossen. Mach beim Server das Sleep kleiner...

0 zum beispiel ;)
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 02.01.05 21:09 
Zitat:
Das eine Programm (Client) beendet sich sofort nach connect wieder

Tut es eben nicht!!! :(

Wenn ich den Sleep auf 0 setzte, rattern beide Progs die Schleife durch und verbrauchen wahnsinn viel Resourcen und der Client connected nicht...

:cry:

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 02.01.05 21:11 
geht denn wenigstens der Server aus?
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 02.01.05 21:32 
Nein!! Keines von beiden!!! :shock: Ich raff's nich'!!! :?

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 02.01.05 21:36 
mach halt wie ich ein application.processmessages und alles funzt wie es sollte