>
> There's always a better way and always a simpler way to do anything but
> not always both at the same time :-)
>

I find everything's getting more inferior and harder at the same time.

But the good news is that a sanity check using a TcpListener and TcpClient
pair works the way I want between my work machine and the VM.

The server is a bit ugly because I need a background thread running to
AcceptTcpClient
<https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.accepttcpclient(v=vs.110).aspx>
and add them to a collection. There is no way to cancel that method, so
when the process ends it just dies. The server uses IPAddress.Any so anyone
can connect. Logging is written to the network stream of each known client.
If a write fails then the client is assumed dead and removed from the
collection.

The client just connects and reads bytes in a loop. There is no formal way
I can find of cancelling this method either. I notice that many rapid
writes from the server will arrive in the client via a single read, but I
guess that's the way it's designed to work!

So it all works, and it's an acceptably small amount of code. It's ugly
that there's no way of elegantly closing the server and client, the client
can Close, but you have to catch errors to possibly know when to finish
working.

*GK*

Reply via email to