Call Windows Service from Browser - c#

I want to send data to a driver software via browser application with in same machine. If this driver can keep on listening to external connection via socket as a windows service, can I write a web application to send data to this driver by using php, applet or .net. Driver is written in C#. Is this possible and if so can someone show me a path/suggestions or any resource related to this?

I do not know a whole lot about drivers...
But, if you can self-host a WCF service in the C# driver, than you can do IPC (inter-process communication) on the same machine. The WCF could expose multiple endpoints ie.) http, namedpipe, or tcp and the .NET web application can subscribe to the service and send data to the C# driver.
Also, if you use a http or tcp endpoint, i believe that the web application would be able to connect to the C# driver from another machine.
WCF Reference: http://msdn.microsoft.com/en-us/library/ms731082.aspx

you could use web sockets WebSocket, however your driver would have to handle the handshake.

Related

How to send request from rest API to Windows Application

as the question says, how can I communicate from a rest API to Windows application. I have Windows application that connects to a linux server over TCP connection. This application manages multiple connections (around 7-8k tcp connection on different ports and keeps alive these connections all the time.). I have a mobile application that connects to rest API (APS.net C#) and works as expected. Now i want to send some more information from linux server to mobile client. How can I send a request from rest API to windows application and get response to send it to mobile application when requested from mobile. This communication between API and Windows application should be asynchronous and could handle around 7-8k connections without delay. How can i achieve this? Is it possible to achieve this using current architecture? or should I change it? I am willing to adopt any proposed architecture or new framework and any other programming language which serves the purpose good. Here is rough structure.
I think you can try using SignalR, it allows for dual communication between client and serer
It uses websockets as its underlying connection and you can either send messages to all connected clients or a specific client.
https://dotnet.microsoft.com/apps/aspnet/signalr

What is the best way for a .NET client application to connect to a WebSocket server?

I want to develop a Windows Desktop application (.NET 4.5.2) which should connect to a extern provided Server via WebSocket and consume events/notifications. The server pushes the data JSON-coded to the client.
Unfortually the SignalR client library only supports SignalR WebSockets.
I want to connect to a URI like this: ws://servername:port/socket.
What is the best library or a valid way to connect to such a server?
you can achieve this with ClientWebSocket library read more here
it has support for.net 4.5,there is an example here

Web Socket between C# Console Application and a browser

Is it possible (and simple) for C# console to open a web socket with a browser, without using Node.js? Meaning, an active and opened C# console application, always running on the server, which can send and receive messages to and from the browser at real time.
I tried to use a browser loading the socket.io.js JS file (https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js), and creating a C# console application using TcpListener class. And there seems to be a successful connection. But I can't send messages between the server and the client.
Yes, I've done it several times.
C# console / Windows service: Use SignalR library. Should be able to get it via NuGet.
Web application: Use jquery.signalr-x.x.x.js library.
SignalR should primarily establish a WebSocket connection between the SignalR hub in our .NET app, and the jquery.signalr client library in your web application.

Read Client side Serial Port in ASP.NET C#

i need help in reading clients Serial port (COM port) from my web application.
i am able to read it on windows application but if i wants to put it over the web.
is it possible to do so?
I could be wrong, but I don't think it's possible to read a serial port (or indeed any type of port) directly from the browser because there isn't going to be any interface to the underlying system hardware, etc.
However depending on what you need to do there are a couple of options (and probably more that I haven't thought of)
Browser plugin
You could write a browser plugin that can do whatever it wants (within the limitations of a browser plugin of course) and can be used by your webpage by injecting the serial data feed into the page.
The problem with this would maybe having to create plugins for all browsers (assuming you want the web application to run on whatever browser the user chose)
Self-hosted WebAPI in a desktop app
You could embed a self-hosted Web API into either your existing desktop app or a tray application / Windows service, etc, that interfaced with the serial port as you currently do.
This app or service would read the data and "publish" it via a simple JSON-based api that your web app can GET (or could use web sockets to push the data once the initial connection is made by the web app) and could also accept commands from the web browser via POST, etc.
Your web application could then access this via HTTP to get the data and do whatever it liked with it.
Either way, I think the user is going to have to install something to their local system for this to work.

Connect Windows Mobile to client PC over WIFI

What would be the best way to transfer a string across a network from a windows mobile device(so .net) to a .net app running on a pc on the same wifi network?
Would normal sockets work or would i use something like a webrequest?
The client can be any version of .net.
Thanks
For application there is no matter what type of connection is used, because it is incapsulated inside net-related classes.
On desktop you may use
TcpListener http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx
HttpListener http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
WCF
Web Service
ASP.NET Handler
These classes allows you to map some URL like http://{PC-name}/somepath to code executed by your applcation.
On mobile device you may use some classes allows you to make request using that URL. Also if your desktop application publish web service or WCF service, you may add reference to this service to mobile application and get strongly-typed interface to operate with desktop application. It is preferred way as for me.

Categories

Resources