Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono Compatible Networking/Socket Library [closed]

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.

like image 225
Adam Haile Avatar asked Sep 11 '09 03:09

Adam Haile


People also ask

What is a socket library?

A socket library is a library that implements sockets so that you can use them in your program for Internet communication.

What is the use of socket library?

The socket library is a low-level programmer's interface that allows clients to set up a TCP/IP connection and communicate directly to servers. Servers use sockets to listen for incoming connections, and clients use sockets to initiate transactions on the port that the server is listening on.

Which of the following function binds the socket to the provided address and port?

int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen); The function bind assigns an address to a socket. This is necessary on the server side so that a port number for the socket is known.


3 Answers

Something like this now exists, checkout networkComms.net. Does all of the things you require and is also 100% compatible with mono.

Disclaimer: I am one of the developers for this commercial library.

like image 60
MarcF Avatar answered Sep 21 '22 06:09

MarcF


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.

like image 27
feroze Avatar answered Sep 20 '22 06:09

feroze


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.

like image 31
holsee Avatar answered Sep 20 '22 06:09

holsee