C# Single-Connection TCP Listener

Job ID: 40145677

Budget: $30 – $250 USD

I’m looking for a clean, well-documented C# class that wraps System.Net.Sockets to act as a TCP listener on a user-supplied IP address and port. The listener must accept exactly one client connection at a time; while that link is active every further connection attempt has to be refused immediately. As soon as the current client disconnects, the socket should reopen and wait for the next caller.

Core behaviour
• Variable-length messages arrive over the open connection. I need the class to detect each complete string in turn and hand it back through a public event, callback, or virtual method—one string at a time.
• Messages are processed independently; no automatic concatenation.
• Any runtime issue should raise or return a clear error code/message to the caller. No file logging or automatic restart logic is required.

Minimal public surface
Constructor(IPAddress ip, int port)
StartListening() / StopListening()
event OnMessageReceived(string data)
event OnSocketError(int code, string message)

What I expect to receive
1. Full source code for the class, compiling under the current LTS .NET version.
2. A short example (console app or unit test) that shows start-up, message handling, and graceful shutdown.
3. Inline XML comments or similar so future developers can plug the code straight into their projects.

Please keep the implementation lightweight and free of external dependencies beyond the standard library.