Need Help With Packet Length

Reply

Join Date: Jul 2006
Posts: 2
Reputation: Derickd is an unknown quantity at this point 
Solved Threads: 0
Derickd Derickd is offline Offline
Newbie Poster

Need Help With Packet Length

 
0
  #1
Jul 10th, 2006
42 00 02 E3 0B 06 1E CD 78 C1 47 B5 A5 00 8E 69
E2 32 67 00 00 00 75 85 00 00 00 00 00 00 00 00
00 00 64 65 72 69 63 6B 00 41 72 65 73 20 31 2E
39 2E 31 2E 33 30 31 30 00 C0 A8 00 04 CC 6F 6B
57 01 00 06 00

Thats the packet I need to send to connect to a chatroom. In that packet, it includes username, number of shared files, Internet Speed, Client Version.

When I send the packet like that, it connects to the room I want under my settings. I want the settings to be optional, so they can connect with thier own username, shared files, internet speed. But when I go to send that packet replacing sertain parts of the packet with username.text and what not, it connects to the room and then disconnects. This is because of the packet length. Im using TtcpClient.

I tried this but it doesnt work TcpClient1.Sendln (Length(#$02+#$E3+0B+Username.text+#$A5+#$00 - ect ect ect, but it gets me no where.

So, could someone help me with setting the packet length so others who use my client will be able to do thier own settings?
Here is how your suppose to connect:
login procedure:

client -> MSG_CHAT_CLIENT_LOGIN
{ payload:
16 BYTE my GUID
2 WORD my shared count
1 BYTE skipped
2 WORD my data port
4 DWORD my supernode ip
2 WORD my supernode port
4 DWORD my 'declared' speed
variable len char (null terminated) my nick
variable len char (null terminated) client version


Here is a picture of my client: http://img170.imageshack.us/my.php?i...tclient7bf.jpg

Please and thanks!
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 71
Reputation: Micheus is an unknown quantity at this point 
Solved Threads: 4
Micheus's Avatar
Micheus Micheus is offline Offline
Junior Poster in Training

Re: Need Help With Packet Length

 
0
  #2
Jul 10th, 2006
Originally Posted by Derickd
...
I tried this but it doesnt work TcpClient1.Sendln (Length(#$02+#$E3+0B+Username.text+#$A5+#$00 - ect ect ect, but it gets me no where.
...
variable len char (null terminated) my nick
variable len char (null terminated) client version
...
Does not the sequence "#$02+#$E3+0B+Username.text+#$A5+#$00 - ect ect ect" must to include null terminator after username? Like "#$02+#$E3+0B+Username.text+#$00+#$A5+#$00 - ect ect ect".

sorry my poor english.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Need Help With Packet Length

 
0
  #3
Jul 11th, 2006
Hi,

I don't think your problem is the packet length, because there isn't a length field in the MSG_CHAT_CLIENT_LOGIN structure; and when you use " TcpClient1.Sendln (Length(#... " you just send the length followed by CR LF (#13#10) because of the SendLn. You must declare a structure type in Delphi using
Pascal and Delphi Syntax (Toggle Plain Text)
  1. type MSG_CHAT_CLIENT_LOGIN = record
  2. GUID : Array [0..15] of byte;
  3. mySharedCount : integer;
  4. skipped : byte;
  5. myDataPort : inteer;
  6. .
  7. .
  8. .
  9. end;
you must fill a variable of this type with appropriate data and send it using TcpClient1.Send() passing it's address using @ operator.

Loren Soth
Best regards,
Loren Soth

Crimson K. Software _________________________________________________________________ Crimson K. Blog
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Need Help With Packet Length

 
0
  #4
Jul 11th, 2006
Hi,

As Micheus stated in his post you should put the nick and client version ending with #0 instead of Delphis own String type. The MSG_CHAT_CLIENT_LOGIN structure you provided doesn't seem to fit on the hex packet data you provide. The structure doesn't contain a variable for length but the first word seems to be the data length. (how did yo figured out?) You can use PChar or PCharArray types for null-terminated strings in Delphi but they require manual allocation of memory. I searched and seems that the structure you are using is from ares Delphi client you can google "MSG_CHAT_CLIENT_LOGIN" or "ares" to find the sourceforge web site of the project, they have the complete Delphi source.

Loren Soth
Best regards,
Loren Soth

Crimson K. Software _________________________________________________________________ Crimson K. Blog
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 2
Reputation: Derickd is an unknown quantity at this point 
Solved Threads: 0
Derickd Derickd is offline Offline
Newbie Poster

Re: Need Help With Packet Length

 
0
  #5
Jul 12th, 2006
Originally Posted by Lord Soth
Hi,

As Micheus stated in his post you should put the nick and client version ending with #0 instead of Delphis own String type. The MSG_CHAT_CLIENT_LOGIN structure you provided doesn't seem to fit on the hex packet data you provide. The structure doesn't contain a variable for length but the first word seems to be the data length. (how did yo figured out?) You can use PChar or PCharArray types for null-terminated strings in Delphi but they require manual allocation of memory. I searched and seems that the structure you are using is from ares Delphi client you can google "MSG_CHAT_CLIENT_LOGIN" or "ares" to find the sourceforge web site of the project, they have the complete Delphi source.

Loren Soth
I know they do, I have the source but im creating my client threw packets, the source code for ares is half in french. But anyway, MSG_CHAT_CLIENT_LOGIN = 02. I got it to connect but it aint going threw my EXACT settings.

Pascal and Delphi Syntax (Toggle Plain Text)
  1. procedure TForm1.WinsockConnect(Sender: TObject);
  2. begin
  3. VersionInfo := 'Ares Chat Client 1.0';
  4. Username := User.Text;
  5. Filesa := Files.Text;
  6. Winsock.Sendln(#$48+#$00+#$02+#$E3+#$0B+#$06+#$1E+#$CD+#$78+#$C1+#$47+#$B5+#$A5+#$00+#$8E+#$69+#$E2+#$32+#$67+IntToStr(Length(Filesa))+#$00+#$00+#$75+#$85+#$00+#$00+#$00+#$00+#$00+#$00+#$00+#$00+#$00+#$00+Username+#$00+Versioninfo+#$00+#$C0+#$A8+#$00+#$04+#$CC+#$6F+#$6B+#$57+#$01+#$00+#$06+#$00);
  7. end;
That works but its sending the files amount wrong, any sujestions?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC