简体   繁体   中英

Is it possible to read data from a local port using Javascript or ASP.NET?

I written the following to broadcast a data in a Windows Application using C#

 UdpClient server = new UdpClient("127.0.0.1", 9050);

            string welcome = "Hello, are you there?";
            data = Encoding.ASCII.GetBytes(welcome);
            server.Send(data, data.Length);

But, How can I read the same data by a web application using javascript or asp.net?

You can do this via a webservice or wcf service. Javascript can be serialized into JSON. Have a look at the json website to check out the syntax. I have used JQuery to do the ajax communication to call the webservice in the past. The all you need to do to convert this back to a javascript object is

var myObject = eval(myTransferObject)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM