Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 21:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Using CO socket for another job ...

Discussion on Using CO socket for another job ... within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
abdeen's Avatar
 
elite*gold: 0
Join Date: Mar 2010
Posts: 475
Received Thanks: 15
Lightbulb Using CO socket for another job ...

Hello Epvp members ...

i am using co socket with all socket files which in source to make a server/client apps for for any job like chatting or file transfer .. etc .

now i can connect to server through client .. and i can send byte`s .. but i wanna make the client just like a conquer client ... i mean i want it working with packets not bytes ... i know the packets is a something like decrypted bytes but i wanna explain it like this :

Conquer online Login packet

Code:
#region LoginPacket (1052)
                case 1052:
                    {
                        if (client.Action == 1)
                        {
                            Connect connect = new Connect();
                            connect.Deserialize(packet);
                            AppendConnect(connect, client);
                        }
                        else
                            client.Disconnect();
                        Console.WriteLine("Disconnect 5");
                        break;
                    }
                #endregion
i can send bytes like this ..

Code:
 byte[] data = new byte[276];
            Begin_Send(data);

and here is begin send void

Code:
        void Begin_Send(byte[] Message)
        {
            try
            {
                ClientSocket.Send(Message);
            }
            catch (Exception g) { Update_Screen(g.Message); }
        }
Code:
ClientSocket = new WinSocket();
i am using full co socket in server side ... and just used WinSocket.cs file from conquer socket files in my Client ...

but i wanna it handle or contains User id and password if my app needs to login or something like conquer ....

any suggest idea ?

sorry for my bad English ... long time not using it ..
abdeen is offline  
Old 08/19/2013, 09:56   #2
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
im not sure if you entirely understand the concept of packets, so ill explain it briefly
a packet is a byte[] with a constant structure for the first 4 bytes and last 8 bytes (talking about conquer packets)
first ushort is length, second ushort is type, and last string is the sealing

if you are trying to send a packet as a structure it should end up sending a byte[] (atleast that's what it did on c++ last time i tried)

let me explain what it really does at the example you gave us
lets just stick with the fact that packet is a byte[] with structure for every type

it first switch on the type of the packet with something like

Code:
switch (BitConverter.ToUInt16(Packet, 2))
{
case 1052:
                   {

                   }
}
and then it creates a new instance of the class Connect which it then calls a function inside calls "Deserialize" which mainly assign the byte[]/packet you pass as parameter to another byte[]/packet inside this class
which let the other properties read and write to it

i don't currently have any of trinity bases to get code snippet but it's basically something like

Code:
public class Connect 
{
public byte[] packet
//ctor
        public uint Identifier
        {
            get { return ReadUInt32(4); }
            set { WriteUInt32(value, 4); }
        }
        public Deserialize (byte[] _packet)
        {
            packet = _packet
        }
//dtor
}
back to what you really want
conquer login sequence is a bit complicated if you don't really understand the crypto behind it, but lets put the crypto away
all you need is to auth the player which requires on packet sending the username and password
then you can either follow tq logic of having 2 instances with 2 connections, one of each for login/auth and the other for the game, where you are not allowed to login to the game server without first passing the login/auth server
or you may use a simpler logic of having just one connection with one instance with a bool property indicating the verification status, that being set by matching the account and password from the database to true and to false whenever it doesn't or the account disconnect
which will decide later to forward packets and analyise it from this connection or just drop the connection

so all in all, packet is a byte[] and i've mentioned above how it works
go for it is offline  
Thanks
1 User
Old 08/25/2013, 14:21   #3
 
Danial Eugen's Avatar
 
elite*gold: 0
Join Date: Sep 2012
Posts: 171
Received Thanks: 68
You may also take a look at my simple socket tutorial

Danial Eugen is offline  
Thanks
1 User
Reply




All times are GMT +1. The time now is 21:04.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.