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?image=chatclient7bf.jpg

Please and thanks!

Member Avatar for Micheus

...
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". :confused:

sorry my poor english.

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

type MSG_CHAT_CLIENT_LOGIN = record
  GUID : Array [0..15] of byte;
  mySharedCount : integer;
  skipped : byte;
  myDataPort : inteer;
  .
  .
  .
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

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

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.

procedure TForm1.WinsockConnect(Sender: TObject);
begin
VersionInfo := 'Ares Chat Client 1.0';
Username := User.Text;
Filesa := Files.Text;
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);
end;

That works but its sending the files amount wrong, any sujestions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.