views:

373

answers:

3

Are there any Mono (C#) compatible networking / socket libraries out there?

Preferably something that is:

  • Multi Threaded
  • Event Driven
  • Capable of multiple connections
  • Handles client and server pieces
  • Runs on Mono and MS .NET runtimes
  • Very simple
  • Free (And usable in commercial software)

It would also be really great if it was:

  • .NET Compact Framework (Windows Mobile) compatible
  • MonoTouch (iPhone) compatible

Edit:

To clarify more, what I meant by my "one level above TCP/IP" comment was that I want something that is basically a self contained server / client. I don't want to have to deal with writing the threading code, handling each connection, etc. For example, I would love for the code to look like this:

Server s = new Server(8080);
s.NewConnection += new ConnectionEventHandler(NewConnection);
s.DataRecieved += new DataEventHandler(NewData);
s.Start();

void NewConnection(object sender, EventArgs e)
{
   s.Send((Connection)sender, "Hello World!"); //(Connection)sender is the connection instance so the server knows which to send the response to
}

void NewData(object sender, EventArgs e)
{
   s.Send((Connection)sender, e.Data); //Echo back
}

Not the cleanest code, but I think it gives the basic idea.

A: 

I am not clear as to what exactly you expect from a class that is "one level above TcpClient and TcpListener"?

TcpClient/TcpListener are the basic building blocks you should use for development. I am not sure if they are supported in Mono as well, but if they are, then it should be all you need.

.Net CompactFramework also supports these, although I am not sure about Mono Touch.

feroze
By "one level above" I mean that I don't want to deal with writing the threading code, handling multiple connections, etc... see updated question above...
Adam Haile
+1  A: 

No, there is nothing out of the box that does what you want.

TcpClient/TcpListenr are already one level above Socket class. If you really want something that is even simpler, it is a very easy task to wrap TcpListener() and make it expose the event handler entry points that you want.

feroze
Strange... it just seems weird that this hasn't already been done. Every time I do something that uses sockets I end up writing basically the same code over again... figured someone would've already done it and packaged it in a nice library.
Adam Haile
A: 

You should check out RemotingLite. I use it with my Mono applications. It was developed to aid in the networking aspect of the Distributed Computing Library MPAPI. MPAPI had a goal of being 100% compatible with Mono.

StevenH