C# Problem Server respons

Inscrit
11 Juillet 2017
Messages
31
Reactions
0
#1
I'm trying to connect to the server for the first time just to see what might happen

My code so far :
C#:
Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sck.Connect(new IPEndPoint(IPAddress.Parse("213.248.126.39"), 443));
            byte[] buffer = new byte[sck.ReceiveBufferSize];
            int n = sck.Receive(buffer);
            Array.Resize(ref buffer, n);
            Console.WriteLine(Encoding.Default.GetString(buffer));
            Console.Read();
And what i get is


Someone explain to me what ma i doing wrong
Ps: sorry for the english but my french is really bad and i can't express what i want to say using french :(
 
Inscrit
15 Novembre 2014
Messages
70
Reactions
0
#2
Something i can respond !

Use this :

C#:
string content_hex = string.Empty;
int huit_bytes = 0;
foreach (byte b in buffer)
{
    content_hex += b.ToString("X2") + " ";
    huit_bytes++;
}
Console.WriteLine(content_hex);
 
Inscrit
11 Juillet 2017
Messages
31
Reactions
0
#3
Can you explain to me what is the "X2" and why you need the variable "huit_bytes" ?
 
Inscrit
24 Juin 2015
Messages
53
Reactions
0
#4
The "X2" shows the hexadecimal representation of the actual byte

Example:

Byte: 13
Hex: 0D

About the hiut_bites I don't know why is in the code too but you can use this variable to know the bytes size but you can avoid it and simply do buffer.Lenght (or count how it apply) to get the bytes count

EDIT: Here shows more ways to do it

https://stackoverflow.com/questions...-array-to-a-hexadecimal-string-and-vice-versa
 
Inscrit
11 Juillet 2017
Messages
31
Reactions
0
#5
Oh i see, So now how can i translate that to understand what the server said ?
 
Inscrit
25 Février 2012
Messages
178
Reactions
3
#6
You can try something like this (if you're sure the server actually responds with text):
C#:
System.Text.Encoding.UTF8.GetString(arrayOfBytes);
Now that I saw your code, if you're trying to handle a Dofus server, you'll have to handle what the server sends to you in bytes and not in text ^^
 
Inscrit
11 Juillet 2017
Messages
31
Reactions
0
#7
I know i'm just trying to figure out what it means so i can respond relatively, Thanks :)
 
Inscrit
25 Février 2012
Messages
178
Reactions
3
#8
That's gonna take more than just converting the bytes to a string.
See dofus servers dont send you plain text (at least not anymore, hi 1.29). They send you bytes for the client to "re-order" and get informations from that ^^
You should check DofusInvoker.swf to see how it works.
 
Inscrit
11 Juillet 2017
Messages
31
Reactions
0
#9
I did Open the DofusInvoker and it was like a bunch of stuff that i don't what is, Can you like point me to where to start understanding the protocol
 

zahid98

Membre Actif
Inscrit
13 Decembre 2014
Messages
352
Reactions
2
#11
Hey ,I see that you're new on this forum so :
dofus server communicates differently with his clients . Obviously , all these communication methods can be found on the client sources (ref. the message before this one) , dofus client is coded with actionscript 3 which can be easily decompilated with an AS3 decompiler , yet I wont advice doing this before reading the main tutorials of this forum :
https://cadernis.fr/index.php?threads/comprendre-le-protocole-de-dofus.115/
https://cadernis.fr/index.php?threads/tuto-identifier-les-packets.143/
https://cadernis.fr/index.php?threads/de-lanalyse-des-paquets.1056/
Also the code on these tutorials may be outdated so it would be great if you just undersand how it mainly works then you will be given some good dofus emulating/botting projects and samples on wich you could learn .
Besides ,don't be shy and come on our discord server where you can get better help on understanding or translating the tutorials ;) .
And finally don't get demotivated by the language because many people who don't understand french had the patience of learning and now are leading great projects #Genesis .
Good luck and sorry for the bad english .
 
Dernière édition:
Inscrit
15 Novembre 2014
Messages
70
Reactions
0
#12
The "huit_bytes++;" was there to add a carriage every 8 bytes, i forgot to delete it :teeth:
 
Inscrit
11 Juillet 2017
Messages
31
Reactions
0
#13
So if i understood correctly You get the packet id and it's length for the header (the 4 first bits) and then you look for it in the sources then you respond using the source you found right ? So the bot we make is just another client only managed to be a bot Yes?
 
Haut Bas