I have came into a problem with my source, i'm using async sockets and after a while their memory usage increases rapidly, i think it's something related to something called "overlapping", i've tried googling it but couldn't find a solution. Any ideas? or tutorials how to write effecient sockets.
The socket system is inspired by Redux and Phoenix. I've been using this for a while and i think the problem comes from here.
PHP Code:
using System;
using System.Net;
using System.Text;
using System.Linq;
using System.Net.Sockets;
namespace PureConquer.Network.ServerSocket
{
public delegate void NetworkClientConnection(Wrapper client);
public delegate void NetworkClientReceive(byte[] buffer, int length, Wrapper client);
public class SocketServer
{
public Socket Socket { get; private set; }
public IPEndPoint LocalEndPoint { get; private set; }
public NetworkClientConnection OnConnect;
public NetworkClientReceive OnReceive;
public NetworkClientConnection OnDisconnect;
public BruteForceAttackProtection AttackProtector;
public int ClientBufferSize;
public SocketServer(uint maximum = 50, uint banTime = 60)
{
AttackProtector = new BruteForceAttackProtection(maximum, banTime);
}
public void Prepare(int port, int backlog, IPProtectionLevel protectionLevel)
{
LocalEndPoint = new IPEndPoint(IPAddress.Any, port);
Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket.Bind(LocalEndPoint);
Socket.SetIPProtectionLevel(protectionLevel);
Socket.NoDelay = true;
Socket.Listen(backlog);
}
public void InvokeOnConnect(Wrapper client)
{
if (OnConnect != null)
OnConnect(client);
}
public void InvokeOnReceive(byte[] buffer, int length, Wrapper client)
{
if (OnReceive != null)
OnReceive(buffer, length, client);
}
public void InvokeOnDisconnect(Wrapper client)
{
if (!client.IsAlive) return;
if (OnDisconnect != null)
OnDisconnect(client);
}
}
}
PHP Code:
using System;
using System.Net;
using System.Text;
using System.Linq;
using System.Net.Sockets;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace PureConquer.Network.ServerSocket
{
public class Wrapper
{
public Socket Socket { get; private set; }
public SocketServer Server { get; private set; }
public IPEndPoint RemoteEndPoint { get; private set; }
private readonly byte[] _buffer;
public object Owner;
public Boolean IsAlive { get { return Socket.Connected; } }
public String IP
{
get
{
if (Socket != null)
return (Socket.RemoteEndPoint as IPEndPoint).Address.ToString();
else
return null;
}
}
public Wrapper(SocketServer server, Socket socket, int bufferLength)
{
Server = server;
Socket = socket;
_buffer = new byte[bufferLength];
RemoteEndPoint = (IPEndPoint)Socket.RemoteEndPoint;
Socket.NoDelay = true;
}
I read somewhere that the socket system used in redux is flawed I don't know if you are using it or what's the problem with it since I didn't really touch it but yeah , you may want to use a different socket system or fix the flaws whatever they are.
Yeah, that queue looks suspicious, also maybe if you are using unmanaged code in your cipher you might be leaking memory? These are just shots in the dark though.
Yeah, that queue looks suspicious, also maybe if you are using unmanaged code in your cipher you might be leaking memory? These are just shots in the dark though.
i'm using co2_core_dll of cptsky's and when i memory profiled it i saw that something called biginteger uses a huge memory but i think it's get collected by the GC, so i never bothered but idk honestly but reading the comments the socket system seems to be fine.
crap edit do not bother wasting time looking at 05/20/2007 - CO2 Guides & Templates - 8 Replies anyways here is my first attempt at editing at spell and yes i know i went a bit mad with the editing the ss but its still good xD
Blue lines nado xD
http://i172.photobucket.com/albums/w2/Jaspermanpi cs/bluelined.jpg
Why bother anymore? 01/12/2007 - Conquer Online 2 - 13 Replies Not trying to just complain, but why bother anymore writing anything for CO? It's doomed, the game is made only for those that pay, so unless you have a way to hack money or dup items (both server based and something I have been trying to figure out a way around by packet spoofing with no luck), I just don't see the point anymore. I figure in another couple of months it will be closed up anyway, better off using my time on other projects. Thoughts?
Y does bot bother people so much? 12/11/2006 - Conquer Online 2 - 3 Replies Yes but we really do find it funyn that the only people who actually want the bots are the people with like 20 posts/0 karma...and probably dont even know how to play conquer properly ^^ the rest of us realise that COpartner has ruined the game. And while im on a roll i would like to add that some of us dont really care about the bots but the select few people we actually like and we are here for the community rather than the freebies. Kthnxbai
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...