Skip to content

Commit b2d13c5

Browse files
committed
fix bug
1 parent dd5b580 commit b2d13c5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Network.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public interface NetHandler
127127
public class NetManager
128128
{
129129
private bool inited = false;
130+
private bool running = true;
130131
private readonly List<NetHandlerImpl> sockets = new List<NetHandlerImpl>();
131132
private readonly List<NetHandlerImpl> newsockets = new List<NetHandlerImpl>();
132133
private readonly List<NetHandlerImpl> deletesockets = new List<NetHandlerImpl>();
@@ -186,7 +187,7 @@ private void Init()
186187

187188
byte[] bytes = new byte[64 * 1024];
188189

189-
while (true)
190+
while (running)
190191
{
191192
if (newsockets.Count > 0)
192193
{
@@ -231,7 +232,7 @@ private void Init()
231232
if (socket.need_send)
232233
writers.Add(socket);
233234
}
234-
Socket.Select(reads, writers, errors, -1);
235+
Socket.Select(reads, writers, errors, 5);
235236
for (int i = 0; i < writers.Count; i++)
236237
{
237238
NetHandlerImpl socket = writers[i];
@@ -340,7 +341,7 @@ public void Listen(int port, Accepted callback)
340341
}
341342
}
342343
ctrl.Callback = callback;
343-
while (true)
344+
while (running)
344345
{
345346
if (!server.Server.Poll(1000, SelectMode.SelectRead))
346347
{
@@ -385,6 +386,11 @@ public void Stop(int port)
385386
}
386387
}
387388

389+
public void Exit()
390+
{
391+
running = false;
392+
}
393+
388394
public delegate void Connected(NetHandler handler, bool success);
389395

390396
public NetHandler Connect(string ipport, int timeout)
@@ -610,7 +616,7 @@ public void Write(IntPtr bytes, int length)
610616
}
611617
}
612618

613-
public NetListener Listen
619+
public new NetListener Listen
614620
{
615621
get { return listen; }
616622
set { listen = value; }

0 commit comments

Comments
 (0)