修正发送pool bug

This commit is contained in:
sin365 2021-12-27 23:52:27 +08:00
parent af0e472b42
commit 4cb9797f4a
3 changed files with 28 additions and 26 deletions

Binary file not shown.

View File

@ -318,19 +318,18 @@ namespace HaoYueNet.ServerNetwork
void IO_Completed2(object sender, SocketAsyncEventArgs e) void IO_Completed2(object sender, SocketAsyncEventArgs e)
{ {
// determine which type of operation just completed and call the associated handler // determine which type of operation just completed and call the associated handler
Console.WriteLine("就他妈从来没进过");
switch (e.LastOperation) //switch (e.LastOperation)
{ //{
case SocketAsyncOperation.Receive: // case SocketAsyncOperation.Receive:
ProcessReceive(e); // ProcessReceive(e);
break; // break;
case SocketAsyncOperation.Send: // case SocketAsyncOperation.Send:
ProcessSend2(e); // ProcessSend2(e);
break; // break;
default: // default:
throw new ArgumentException("The last operation completed on the socket was not a receive or send"); // throw new ArgumentException("The last operation completed on the socket was not a receive or send");
} //}
} }
// This method is invoked when an asynchronous receive operation completes. // This method is invoked when an asynchronous receive operation completes.
@ -546,7 +545,7 @@ namespace HaoYueNet.ServerNetwork
sendrun--; sendrun--;
Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!"); Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!");
} }
catch(Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
@ -570,6 +569,9 @@ namespace HaoYueNet.ServerNetwork
myreadEventArgs.AcceptSocket = token.Socket; myreadEventArgs.AcceptSocket = token.Socket;
myreadEventArgs.SetBuffer(message, 0, message.Length); //将数据放置进去. myreadEventArgs.SetBuffer(message, 0, message.Length); //将数据放置进去.
token.Socket.SendAsync(myreadEventArgs); token.Socket.SendAsync(myreadEventArgs);
//得了,先回去吧
m_Sendpool.Push(myreadEventArgs);
return; return;
} }
else else