Skip to content

Instantly share code, notes, and snippets.

@binaryPUNCH
Last active September 9, 2016 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binaryPUNCH/377cd9ce192b85defac01fd285f9755e to your computer and use it in GitHub Desktop.
Save binaryPUNCH/377cd9ce192b85defac01fd285f9755e to your computer and use it in GitHub Desktop.
// Sending client
private void UpdateServer()
{
string headJSON = JsonConvert.SerializeObject(head); // head is class for the snake's head object
byte[] msg = Encoding.ASCII.GetBytes(headJSON);
int bytesSent = socketSender.Send(msg);
}
// Receiving-end socket listener
byte[] bytes = new byte[1024];
int bytesRec = handler.Receive(bytes);
String headJSON = Encoding.ASCII.GetString(bytes, 0, bytesRec);
Head receivedHead = JsonConvert.DeserializeObject<Head>(headJSON); // Deserialization of "hard-coded" datatype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment