To send a binary JSON message to a TCP server in C#, you need to do the following:
Here's some sample code that demonstrates this approach:
main.cs777 chars31 lines
In this example, we create a sample data structure with a name and age field. We then serialize this structure to binary JSON using MessagePack.
We then create a new TCP client and connect to a server running on localhost on port 1234. We get the stream associated with the socket and send the binary JSON message over the stream using the Write method.
Finally, we close the stream and the client to cleanup resources.
gistlibby LogSnag