Autor Beitrag
Zello.de
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 31.05.06 17:38 
hallo
ICh probiere im moment einfach mal mit den Komponenten Serversocket und Clientsocket rum.
Zur ueit habe ich 2 Programme, die auf meinem pc laufen-> Client und Server.
Mit dem Client connecte ich auf den server und schicke einen Text, den der server auch empfängt. So weit hatte ich keine Probleme. Wenn ich mit dem server an den Client senden will geht das jedoch nicht (Das Programm gibt die Fehlermeldung:"Socket nicht verbunden...keine Adresse angegeben" aus). Is ja auch logisch das Server nich weis wo er das hinschicken soll, aber wie soll ich ihm das "mitteilen"?

ich habe es versucht mit:

Serversocket1.Socket.SendText('bla');

Was muss ich vorher tun?

Danke im Vorraus
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 31.05.06 17:40 
Das ist ein alter Fehler ;)
So muss es heißen:
ausblenden Delphi-Quelltext
1:
serversocket1.socket.connections[0].sendtext('blubb');					

In den eckigen Klammern steht der Index der Verbindung, da ein Server sich ja mit mehreren Clients verbinden kann.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Zello.de Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 31.05.06 17:47 
thx für die schnelle antwort^^
is genau das was ich gesucht hab.
WIe weis ich aber an welchen client ich sende? Klar an der im Array an der Stelle 0 steht, aber wenn ich 3 clients hab und ich will nur an den einen was senden, woher weis ich welcher client welche nummer hat? Geht das nach der reihenfolge der Anmeldung? aber selbst dann weis der Server ja nicht wer sich zuerst anmeldet, oder?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 31.05.06 17:55 
Das geht nach der Reihenfolge der Anmeldung.
Du könntest die Computernamen vom Client an den Server senden, in einem Array abspeichern und dann kannst du das Array durchsuchen und bekommst damit den Index. Das Sammeln im Array könnte so funktionieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var i:integer;
begin
for i := 0 to serversocket1.Socket.ActiveConnections-1 do
begin
if socket=serversocket1.socket.connections[i] then array[x]:=socket.receivetext;
end;
end;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Zello.de Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 31.05.06 18:02 
Danke =)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 31.05.06 18:03 
Darf ich fragen, was das für Programme sind, die miteinander kommunizieren?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 31.05.06 18:16 
würd mich auch mal interessieren.
Zello.de Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 31.05.06 19:39 
klar...
In Informatik(Stufe 11) machen wir grade Projekte und da hab ich Mau Mau ggn den Computer programmiert. Nachdem ich das Spiel ggn den Computer fertig hatte, und jemand anderes aus meinem Kurs irgendwas mit Netzwerk gemacht hat, hab ich mir das auch mal angeguckt.
Die 2 Programme die im Moment miteinander komunizieren schicken sich einfach nur textmessages hin und her, also eig. nen kleiner netzwerk-chat. Aber irgendwann soll man mal Mau Mau ggneinander spielen können.
so...
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 31.05.06 20:06 
aha. bau doch einfach in dein netzwerk mau-mau noch eine chat-funktion ein. das is interessanter als NUR mau-mau
Zello.de Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 31.05.06 21:44 
jo^^ aber das is ja dann eig. nur noch nebensache wenn das netzwerk erst mal fertig ist^^
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 01.06.06 00:40 
Moin!

Da du früher oder später sowieso an diese Stelle kommen wirst, hier gleich noch ein Hinweis: du wirst es sicherlich sehr viel einfacher haben mit deinem Projekt, wenn du dich mal mit dem Begriff Suche in: Delphi-Forum, Delphi-Library PROTOKOLL vertraut machst. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.