C#: Support both HTTP & socket interface - c#

I'm developing an application in C# which should support requests from both HTTP clients & on sockets. Idea is to let users access functionality using HTTP and use sockets for IPC.
Is it possible to have both these interfaces supported in a process?

I would recommend using Windows Communication Foundation for the .NET framework.
http://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx
With it, you can host your application in IIS and offer both TCP and HTTP endpoints.

Yes, that is possible. You probably would open a socket manually for your custom transport, and use an HTTP server library to expose an HTTP endpoint.

Is it possible to have both these interfaces supported in a process?
Yes.
You can read the incoming data as a string, try to parse it using an HTTP library and then decide what to do based on whether it is or not.

Related

call windows service wcf from website using python

I have website build using python and I want to connect with point of sell in the client side
there is any way to send data and get result from windows service or any other way ?
You can create and send an HTTP/HTTPS request according to the configuration and specification of the WCF of the service you want to use.
WCF and Python
How to post complex type to WCF using Python's requests?
However, it may not be possible.
WCF with netTcpBinding + cPython
Please start with obtaining service specifications.

WPF receive GET request's query string sent to localhost socket [duplicate]

I have a C# form application which I want to have listening for incoming HTTP requests from other computers.
How would I go about doing this?
For simple needs, the HttpListener class is a good and simple choice. There is an example on the linked MSDN page.
If, for some reason, you cannot use HttpListener, the process would be to listen to a port using TcpClient (or even the sockets API if you need the gritty details), and then implement the HTTP Protocol. I highly recommend HttpListener over rolling your own, unless you have specific requirements that HttpListener does not meet.
You can use ASP.NET Http Filters to intercept HTTP requests.
See more details here
If it's an asp.net application, you can check the http requests in the Application_BeginRequest event handler of your global.asax.

Why do I need to use WCF to consume an MSMQ?

I'd like to communicate from my web app to an endpoint on a different tier via MSMQ. I've found examples of how to do this by binding with WCF, but not how to with WebAPI.
Why do I have to use WCF?
Are they any other alternatives?
Other than WCF's netmsmqBinding, you could also obviously use the more native System.Messaging.MessageQueue .Net classes to read and write directly from queues. However, it sounds like you are trying to pull messages from a client such as a browser?
Although you can send messages to MSMQ via Http, you can't receive messages over Http directly.
So TL;DR I believe you will need to write your own capability to receive messages via HTTP / REST etc, e.g. via a WebApi controller action which reads exactly one message and returns same. In doing so you will likely lose any transactional boundary across queue messages.

C# based lightweight application layer protocol - alternative to HTTP

I'm pretty new in C# and I'm developing C#(WPF) application with client/server architecture, and I'll need to communicate between two machines(only short JSONs, however a lot of them), and HTTP is too "heavy" with all it headers etc. Does exist any alternative to HTTP on application layer?
Sure, why not use WCF.
That way you can specify the type of communication method, named pipes, shared memory, http, tcp etc.
http://msdn.microsoft.com/en-us/library/dd936243.aspx

Looking for a specific type of tcp server

I'm looking for a c# tpc server, or a tcp server that has c# interface, that supports authentication from client to server, maybe via username/passwords or certificates, supports ssl/tls for transport and generally supports incoming channel to forward messages to server and outgoing command channel to send commands to event forwarder, like change this, and perhaps works on Mono as well as Windows, and is performant, i.e. can support multiple (dozens to hundreds of clients), as well as Windows IOCP.
I did look at WCF, but it's too vast/heavy for my requirements.
Thanks.
regards
Bob.
IIS seems like the obvious choice.
Found the following which can be called from c#. Its a high performance Windows IOCP based TCP Server.
http://code.google.com/p/potatofoundation/

Categories