AwesomeSockets
AwesomeSockets copied to clipboard
TcpAccept Memory Leak
I just started checking out AwesomeSockets, so far so good.
One issue....
I'm attempting to make it so the Server can have multiple clients connected at once... To do that, it has to be constantly checking for new connections... I do that like this....
private ServerClass()
{
ISocket listenSocket = AweSock.TcpListen(14804);
// Create a new thread for listening for connections
new Thread(() =>
{
while (true)
{
ISocket socket = AweSock.TcpAccept(
listenSocket,
SocketCommunicationTypes.NonBlocking,
ConnectionCallBack);
}
}).Start();
}
private Socket ConnectionCallBack(ISocket socket, Exception exception)
{
// Do stuff...
return socket.GetSocket();
}
The issue is when I try to make it NonBlocking & use the callback, it seems to constantly grow in size (until an out of memory exception is thrown). Without the NonBlocking it works fine. Like so...
new Thread(() =>
{
while (true)
{
ISocket socket = AweSock.TcpAccept(
listenSocket);
if(socket != null)
{
ConnectionCallBack(socket, null);
}
}
}).Start();
I fixed the issue, by changing....
new Thread(() => TcpAcceptThread(listenSocket, callback)).Start();
to...
while (true)
{
TcpAcceptThread(listenSocket, callback);
}
I think removed my own while loop when calling AweSock.TcpAccept (since it's now in the TcpAccept function.
@shockdot Hmmm... Ill have to look into it...
@shockdot Sorry for the huge hiatus. Are you still seeing this issue? I have released v2.1.15 on nuget. If still applicable, please try it out and tell me if you are still experiencing the same issue.