Rodger
Rodger

Reputation: 143

Sockets with Silverlight application?

I'm trying to use sockets with a Silverlight Application, but it doesn't seem to be working. Here is my code so far:

using System.Net.Sockets;
...
...
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
server.Bind(new IPEndPoint(IPAddress.Loopback, 0));
server.Listen(1);

But I get an error message saying that Bind and Listen are not defined. Does anyone know why this might be?

I using Silverlight 4, with .NET 4.0 (visual studio 2010).

Upvotes: 2

Views: 1276

Answers (3)

Avada Kedavra
Avada Kedavra

Reputation: 8691

The code you have provided is .Net and not Silverlight. There is a big difference between the two as .Net support both synchronous and asynchronous data transfers while silverlight only supports asynchronous mode. Check out the difference on msdn:

The links also have examples on how to use them.

Upvotes: 4

Haplo
Haplo

Reputation: 1368

Silverlight does not allow creation of server sockets. You can only open client sockets and connect to a server.

Upvotes: 0

Davide Piras
Davide Piras

Reputation: 44605

I would use a WCF endpoint on the server which does this communication ( and again, via WCF instead of sockets if possible ), then the SL UI would simply communicate with the ECF endpoint async....

Upvotes: 0

Related Questions