await client listen

This commit is contained in:
waltem01 2022-07-01 07:02:58 +02:00
parent 8f2bb3a4e8
commit 50333f26d6

View File

@ -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