My buffersize is set to max 1024.
Also another thing I've found strange which makes me think it's my mistake.
It only happens with drop (as far as I'm aware.)
My drop handler:
Code:
using System;
namespace ProjectX_V3_Game.Packets.Item
{
/// <summary>
/// Subtype: 37
/// </summary>
public class Drop
{
/// <summary>
/// Handling the Drop action from the ItemPacket.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="item">The item packet.</param>
public static void Handle(Entities.GameClient client, ItemPacket packet)
{
if (client.Inventory.ContainsByUID(packet.UID))
{
Maps.MapPoint Location = client.Map.CreateAvailableLocation<Data.GroundItem>(client.X, client.Y, 3);
if (Location != null)
{
Data.ItemInfo dropitem = client.Inventory.RemoveItemByUID(packet.UID);
if (dropitem != null)
{
Data.GroundItem ground = new Data.GroundItem(dropitem);
ground.DropType = Enums.DropItemType.Item;
ground.X = Location.X;
ground.Y = Location.Y;
Location.Map.EnterMap(ground);
ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(
() => {
Location.Map.LeaveMap(ground);
ground.Screen.ClearScreen();
},
Core.TimeIntervals.DroppedItemRemove);
ground.Screen.UpdateScreen(null);
}
}
}
}
}
}
Nothing that really can disconnect there. There is none of those calls that disconnects.
Since the issue seem to be a buffer issue then this is how I am sending my packets.
Code:
/// <summary>
/// Sends data to the client.
/// </summary>
/// <param name="buffer">The buffer to send.</param>
public void Send(DataPacket buffer)
{
bool PacketSend = false;
try
{
if (buffer.BufferLength > 1024)
{
Disconnect("Too big packet...");
return;
}
byte[] Buffer = buffer.Copy();
if (Crypto != null)
{
lock (Crypto)
Crypto.Encrypt(Buffer);
}
if (PacketSend = Monitor.TryEnter(this, 50))
{
if (clientSocket.Connected)
{
clientSocket.BeginSend(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(Send_Callback), Buffer);
}
else
Disconnect("Not Connected.");
}
}
finally
{
if (!PacketSend)
Disconnect("Lag."); // lag
else
Monitor.Exit(this);
}
}
/// <summary>
/// The callback from Send().
/// </summary>
/// <param name="asyncResult">The async result.</param>
private void Send_Callback(IAsyncResult asyncResult)
{
try
{
int send = clientSocket.EndSend(asyncResult);
if (send < 4)
Disconnect("Did not send proper packet header.");
if (asyncResult.AsyncState != null && send > 0)
{
Array.Clear(((byte[])asyncResult.AsyncState), 0, send);
}
}
catch
{
}
}
As you can see I am not allowing any packets above the size of 1024 bytes to be send.
Although what I should look for is not things that will let the server disconnect the client as it's the client that disconnects.
I'm totally lost whether it's my mistake or a mistake with the conquer client.
#edit noticed you said Socket.SendBufferSize. Will try now.
#edit 2 setting the sendbuffersize didn't work either. Still getting the error.
Quote:
ReleaseVer:F:\CQ2ClientRelease-42.0.1 MsgVer:124, FileTime:2011/07/21,16:24==ERROR: Receive package len[20820] > _MAX_MSGSIZE at ..\3DRole/Network/socket.h, 504 -- Wed Feb 13 16:54:38 2013
[R,cq2clientrelease-42.0.1,5517,English][Win6.2/47M/3658M/1633M/55][18791s/19898s/0s/0s/20050s/20053s/20053s][51814ms/2449=21.16ms] -- Wed Feb 13 16:54:38 2013
|
#edit 3 also found out it does happen with regular send as well, so the problem doesn't exactly lie in BeginSend...