mirror of
https://gitlab1.ptb.de/waltem01/csharpsocketserver
synced 2024-02-04 23:19:43 +00:00
await client listen
This commit is contained in:
parent
8f2bb3a4e8
commit
50333f26d6
|
@ -74,6 +74,10 @@ public static class Connection {
|
|||
own.Listen(1);
|
||||
// Accept any client, stop listening after first client is connected and return client
|
||||
own.BeginAccept(new AsyncCallback(AcceptCallback), own);
|
||||
// Wait for and close connection
|
||||
while (!own.Connected)
|
||||
Thread.Sleep(250);
|
||||
own.Close();
|
||||
}
|
||||
|
||||
// End off the message send-callback
|
||||
|
@ -114,10 +118,8 @@ public static class Connection {
|
|||
Socket other = own.EndAccept(AR);
|
||||
listeners--;
|
||||
other.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), other);
|
||||
if (self == null) {
|
||||
if (self == null)
|
||||
self = other;
|
||||
own.Close();
|
||||
}
|
||||
}
|
||||
|
||||
// Handle sending messages
|
||||
|
|
Loading…
Reference in New Issue
Block a user