c# - Universal Windows App receiving UDP data on a port from any server -


i trying implement udp listener on specific port machine. trying use "new" universal windows project using visual studio 2015.

using wpf "old" type of project following:

public void startlistening() {     this.client = new system.net.sockets.udpclient(5606);     this.endpoint = new system.net.ipendpoint(system.net.ipaddress.any, 5606);     this.client.beginreceive(new asynccallback(receive), this); }  private static void receive(iasyncresult result) {     var self = ((udplistener)result.asyncstate);     var receivedbytes = self.client.endreceive(result, ref self.endpoint);     // receivedbytes     self.startlistening(); } 

however using universal windows seems quite different. there no system.net.sockets.udpclient more. thing can find connecting to/from client/server udp things , stuffs using windows.networking.sockets.datagramsocket. came following:

public async void connect() {     var listenersocket = new windows.networking.sockets.datagramsocket();      listenersocket.messagereceived += listenersocket_messagereceived;      await listenersocket.bindservicenameasync("5606"); }  private void listenersocket_messagereceived(windows.networking.sockets.datagramsocket sender, windows.networking.sockets.datagramsocketmessagereceivedeventargs args) {     throw new notimplementedexception(); } 

but not seem want. never receive data server running in background. wpf version receive data.

what doing wrong? not possible more? can universal windows applications receive data other universal windows applications? or looking @ wrong things here?

with uwp, have so-called "network isolation" mechanism blocks uwp apps doing networking other apps on same machine. have tooling (and registry settings) enable per-app loopback exceptions, available client (not listening) sockets @ uwp app side.

(shot in foot again)


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -