Autor Beitrag
Jocom1029
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Sa 17.07.04 15:16 
hi,

bin delphi anfänger und versuche eine server/multi-client programm zu schreiben.

im moment ist es aber so, das nur der client der sich als erstes am server angemeldet hat die nachrichten vom server empfängt.

das ist mein quellcode vom server mit komponente serversocket
ServerSocket1.Port := 6592; //Festlegung des Ports
ServerSocket1.active := true; //Aktivierung der ServerSocket


mein server on sendestring
form1.ServerSocket1.Socket.Connections[0].SendText(msg);


das ist mein quellcode vom client mit komponente clientsocket
ClientSocket1.Port := 6592; //Festlegung des Ports
ClientSocket1.Host := '192.168.0.13'; //IP des Zielrechners

und der erntsprechende client sende string
ClientSocket1.Socket.SendText(msg);


ich gehe davon aus, das diese komponenten zu einfach für ine multicleint verbindung ist oder?

wie erreiche ich das, das die richtigen daten an den richtigen cleint geschickt werden?


Zuletzt bearbeitet von Jocom1029 am Mo 19.07.04 10:34, insgesamt 1-mal bearbeitet
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 17.07.04 15:24 
Hat der TServerSocket.Socket nicht eine Eigenschaft ActiveConnections?
Mach das in ne for-Schleife und schick jedem aktiven Client ne Nachricht, so wie du bis jetzt dem ersten ne Nachricht schickst...

raziel

_________________
JSXGraph
Jocom1029 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Sa 17.07.04 19:32 
sorry aber ich hab keinen plan wie.

kannst du mir en beispiel geben?

thx
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 17.07.04 19:39 
Ich würd's mal so probieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
varProcedure TForm1.Button1Click(Sender: TObject);
Var
  X: Integer;
Begin
  For X := 0 To ServerSocket1.Socket.ActiveConnections - 1 Do
    ServerSocket1.Socket.Connections[X].SendText('Hello World!');
End;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Jocom1029 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Sa 17.07.04 21:27 
das problem ist, das jeder client unterschiedliche daten empfäng. daher muss der server irgendwie wissen, an welchen client er welche daten sendet. das klappt mit der schleife denke ich nicht.

oder?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 18.07.04 00:17 
Du kannst doch jeden Client eindeutig über seinen Index identifiezieren. Weis doch einfach beim Connected des Clients einen Tag zu. über diesen holst du dir dann die Informationen, was du an diesen Client senden musst. Ich seh nicht, warum das nicht funzen sollte :-D

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Jocom1029 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: So 18.07.04 23:29 
und auch hier wieder meine frage: wie bitte? beispiel?

hab meine komponente auch nur aussem tutorial gezogen und nicht ganz verstanden...
ich kann natürlich den client seine ipsenden lassen, und das im server speichern, aber wie sag ich dem server denn, das er an den client mit ip XY diese nachricht senden soll?

oder wie kann der server jeden client eindeutig identifizieren und ansprechen?

thx 4 help
mfg
jocom1029
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mo 19.07.04 15:19 
Jocom1029 hat folgendes geschrieben:
oder wie kann der server jeden client eindeutig identifizieren und ansprechen?

Dafür hat TServerSocket.Socket.Connections[x] diverse Remote* Eigenschaften. Einfach mal nach dem Connections[x] einen Punkt machen, warten bis ein PopUp aufklappt und mal R-e-m eintippen (ohne "-" natürlich...) und auswählen.

raziel

_________________
JSXGraph