Thursday, March 09, 2006

.Net Remoting for Dummies

I have made my first .Net Remoting application with Visual Studio 2003. I know Remoting has been around since the beginning of the .net framework, but for some reason I'd never used it before. Actually, now I know why I never used it, I did not quite understand what was is it useful for. But a few days ago, while working on Philippides a friend of mine (Carlitos) asked my if I was making all the communication via remoting and I said no, I was using TcpClient and NetworkStream objects in order to send messages.
At first I sent some text (csv) with the info I wanted to send to the other client. Right now I "created" my own SOAP protocol, it's just plain text sent as xml.
What I need to do is to send objects itself to the other client and I need that the receiver can understand the sent object and access its members.
Well, remoting does that for you. In my previous test I managed to send some native types as strings and integers to the server. In this example you'll see that I managed to send an object from a class I created.
So check it out! You can downloading from here or go to the post on the Sandbox ( Channel9).


Acabo de hacer mi primer aplicación .Net Remoting con Visual Studio 2003. Sé que Remoting es bastante "viejo" ya, pero por alguna razón nunca antes lo había usado. En realidad, ahora sé por qué no nunca lo usé, nunca entendí exactamente para qué me podía servir. Pero hace unos días, mientras trabajaba en el Philippides un amigo (Carlitos) me preguntó si todas las comunicaciones las hacía con Remoting y le dije que no, estaba utilizando objetos TcpClient y NetworkStream para enviar mensajes.
Al principio enviaba text (csv) con la información que quería enviar al cliente. En la actualidad utilizo un protocolo SOAP "propietario", es simplemente texto plano enviado como xml.
Lo que necesito hacer es enviar objetos mismos al otro cliente y que este último entienda el objeto y pueda acceder a sus miembros (que fea traducción).
Justamente, Remoting hace eso. En los tests anteriores había logrado enviar tipos nativos de .Net a un servidor como ser string e integers. En este ejemplo verán que pude enviar un objeto de una clase creada por mi.
Asique víchenlo! Pueden bajarlo de aquí o ir al post en el Sandbox ( Channel9).

2 comments:

Sebastián Gómez said...

I've just posted an article with this example at CodeProject.com.
Check it out here!

Anonymous said...
This comment has been removed by a blog administrator.