I agree with bootdisk and a little example of this echo server which i created a few days ago would look like this in for example C#:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;
namespace Silkroad_Login_Server_Example
{
class Program
{
static void Main(string[] args)
{
TcpListener ServerSocket = new TcpListener(15779);
ServerSocket.Start();
Console.WriteLine("Server Started");
Socket Client = ServerSocket.AcceptSocket();
Console.WriteLine("Client Connected");
// Assambling the first packet. (Much easier if you use the packet writer
// from csremu or srevolution. I also ripped this from srevolution.
MemoryStream MS = new MemoryStream();
BinaryWriter BW = new BinaryWriter(MS);
BW.Write((short)1);
BW.Write((short)0x5000);
BW.Write((short)0);
BW.Write((byte)1);
BW.Close();
// Send the packet to the client
Client.Send(MS.GetBuffer(), 7, SocketFlags.None);
// This loop is the main packet loop this one can process all the pakcets from the client
while (true)
{
try
{
// Buffer to store the received packet
byte[] RecvBuf = new byte[4096];
// This function is blocking so it only continues once you receive a packet.
int RecvBytes = Client.Receive(RecvBuf);
// This displays the packet on the console.
for (int i = 0; i < RecvBytes; i++)
{
Console.Write("{0:X2} ",RecvBuf[i]);
}
Console.Write("\n");
}
// Little exception catcher since it throws and exception if the connection got closed
catch (SocketException SE)
{
Console.WriteLine(SE.Message);
break;
}
}
Console.ReadKey();
}
}
}
This code isn't very well designed but I wanted to keep it as short as possible. As you can see I'm using the binairywriter to assemble the packet.
You can see it as an array which you send over the network.
Building this packet in C++ could look like this:
Code:
char Buffer[4096];
*(short*)&Buffer[0] = 1;
*(short*)&Buffer[2] = 0x5000;
*(short*)&Buffer[4] = 0;
*(char*)&Buffer[5] = 1;
Probably the best way to start is learning a programming language till you're comfortable with it and then you can start using sockets and threaded things.
But to get an idea of what you need to do with an emulator is just to simulate a packet but there is a lot of logic behind it so it is very difficult to create a nice and stable one.
And I can give you one good advice. Don't start too soon with adding features. Sure it's nice too see things working but if you take things slow so your emulator will also be more stable. and creating a solid base would also be a good advice. like the client handling cause you probably want a few players online at the same emulator so you need up to date info trough your whole emulator.
How is started with this stuff was a lot of browsing trough other people's sources. sourceforge or assembla or full of emulator projects for mmo's.
I hope this helps you a bit