SimpleSocket

SimpleSocket is a easy to use TCP socket layer built from the group up to support Mono/.NET

Server Code:

SimpleSocketServer server = new SimpleSocketServer(5898);
server.ClientConnected += new ClientConnectedEventHandler(server_ClientConnected);
server.Listen();

static void server_ClientConnected(object server, ClientConnectedEventArgs args)
{
	Console.WriteLine("New Client Connected: {0}", args.Client.RemoteEndPoint);
}

 

Client Code:

SimpleSocketClient Client = new SimpleSocketClient();
Client.Connect("localhost", 5898);
Client.MessageReceived += new MessageReceivedEventHandler(Client_MessageReceived);
Client.Send((int)MessageType.MyUserName, "SimpleSocketUser")

void Client_MessageReceived(object sender, ReceivedMessageEventArgs Args)
{
	MessageType messageType = (MessageType)Args.Command;
	switch(messageType)
	{
		case MessageType.NeedResponce:
			Args.SendResponce(MyObject);
			brea;
		case MessageType.AttachedObj:
			MyObject obj = Args.DataAs<MyObject>();
	}
}

Last edited Jun 13, 2012 at 7:46 PM by rbooth84, version 10