Autor Beitrag
nabbl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 16.08.06 23:40 
Hallo!
Ich habe bisher immer die Indy-Komponenten benutzt und kam mit diesen auch ganz gut klar.
Da ich nun aber Cross-Plattform (mit CrossKylix) programmiere und Indy einfach nicht zum laufen bekommen habe, bin ich auf die Synapse-Sammlung umgestiegen.

Nun suche ich etwas wie bei Indy "TCP.ReadBuffer". Habe schon geguckt und fand "TCP.RecvBuffer". Nur sind da leider die Parameter andere und daher kann man mit der "blcksock"-Unit von Synapse keine records empfangen.

Der zu empfangene Record sieht folgendermaßen aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
 TMsg_Refresh = packed record
    Name : array[1..32of string[PLAYERNAME_CHARS];
    Team : array[1..32of byte;
    Kills : array[1..32of word;
    Deaths : array[1..32of word;
    Ping : array[1..32of byte;
    Number : array[1..32of byte;
    IP : array[1..32,1..4of byte;
    TeamScore : array[1..4of word;
    MapName : string[16];
    TimeLimit, CurrentTime : integer;
    KillLimit : word;
    GameStyle : byte;
  end;


Diesen kann ich auch nicht ändern, da er so vom Server gesendet wird. Wie kann ich nun mit Synapse diesen record empfangen? "TCP.RecvBuffer" akzeptiert nur pointer...

Bitte helft mir :cry: :)
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 16.08.06 23:50 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var myRec:TMsg_Refesh;
begin
  TCP.RecvBuffer(@myRec,sizeof(myRec));
...

Sollte dein Problem lösen. Der @-Operator erzeugt einen Pointer auf den Record. Mich würde mal interssieren, wie du das vorher mit Indy hattest, eigentlich sollte das so ähnlich sein.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 16.08.06 23:55 
ausblenden Delphi-Quelltext
1:
TCP.ReadBuffer(RefreshMsg, sizeof(RefreshMsg));					


Hmm... ich mache nun folgendes:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
    begin
     TCP.RecvBuffer(@RefreshMsg, sizeof(RefreshMsg));
     for i:= 1 to 32 do
     begin
     try
      playernames.Add(RefreshMsg.Name[i-1]);
      playerkills.Add(IntToStr(RefreshMsg.Kills[i-1]));
      playerdeaths.Add(IntToStr(RefreshMsg.Deaths[i-1]));
      playerip.Add(inttostr(RefreshMsg.IP[i-1][1])+'.'+inttostr(RefreshMsg.IP[i-1][2])+'.'+inttostr(RefreshMsg.IP[i-1][3])+'.'+inttostr(RefreshMsg.IP[i-1][4]) );
      playernumber.Add(IntToStr(RefreshMsg.Number[i]));
     finally
      WriteLn('Refreshed...');
      WriteLn(playernames.strings[0]);
     end;
     end;


Da kommt allerdings nur murks raus (vgl. Anhang) :(
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von nabbl am Do 17.08.06 00:40, insgesamt 1-mal bearbeitet
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Do 17.08.06 00:26 
sry 4 doppelpost
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 17.08.06 00:49 
Moin!

ausblenden Delphi-Quelltext
1:
TCP.RecvBuffer(@RefreshMsg, sizeof(RefreshMsg));					

IMHO muss das "@" weg, das ist doch vermutlich als var deklariert. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Do 17.08.06 01:09 
öhm...


user profile iconMartok hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var myRec:TMsg_Refesh;
begin
  TCP.RecvBuffer(@myRec,sizeof(myRec));
...

Sollte dein Problem lösen. Der @-Operator erzeugt einen Pointer auf den Record. Mich würde mal interssieren, wie du das vorher mit Indy hattest, eigentlich sollte das so ähnlich sein.


was denn nun?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 17.08.06 01:14 
Moin!

Probier´s doch einfach aus oder zeig die Parameter-Deklaration der Methode. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 17.08.06 01:35 
Also deklariert ist die wie folgt:
ausblenden Delphi-Quelltext
1:
2:
3:
TMemory = pointer;
.....
function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override;

(zufälligerweise hab ich die Synapse-Doku vor mir ;) )
Also eigentlich braucht man schon das @.

Eventuell mal den Rückgabewert prüfen, ob der gleich Len ist. Wenn nicht, wurde der Record nicht vollständig 'befüllt', was zum Beispiel passiert, wenn die Daten langsamer sind als die Ausleseroutinen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Do 17.08.06 09:48 
Danke für eure Hilfe. Nutze wieder Indy - läuft jetzt komischerweise mit CrossKylix =)