8Monkeys/MonkeyNet — pull request #23 by HaMster21 (2013-08-18 15:21:53+00:00)
Title: Networking basics

This commit is introducing the PeerSocket class that is in place for the low-level IO with the network interfaces. Its default is to set up a InterNetworkv6 UDP socket and bind to port 42337. There is a constructor that is able to bind to a specific endpoint as well.

Once bound, the socket can be set to listen for incoming messages with its Open method. This is done asynchronously using SocketAsyncEventArgs and the ReceiveFromAsync method on the socket member of the PeerSocket class. The SAEA object all have a buffer at the size of the largest MTU of all NICs of the OS. This should allow to receive messages whole, but is varying from OS to OS I guess. This will be addressed in a future release.

Incoming messages are made available as PeerMessage objects that store relevant information. The PeerSocket class fires a "newMessage" event for every incoming message.