views:

59

answers:

3

I need to write a 'server' in c# (.Net 2.0) which would process requests in a specific format and produce a corresponding response in a pre-defined format.

request: (userid);(userpwd);+
response: (user_purchase1);(user_purchase2);(user_purchase3);+

As, I understand this correctly, the server is a standalone module in itself. It should be able to serve to both a website application and a windows application.

I understand the client/server model receives a httprequest and yields an output accordingly, but how can I handle a request in this custom format ?

I'd appreciate any help with this.

Thanks

A: 

You want to take a look at using TcpListener or HttpListener. You can set your server app to listen on any port and handle the requests sent to that port in any custom way you'd like.

brendan
I'm not sure this is what is being asked, although it might be.
spender
+1  A: 

How about hosting a WCF service as a Windows service? See MSDN, How to: Host a WCF Service in a Managed Windows Service.
OR you could just create a simple HttpHandler. Both your website and Windows app should be able to access that just as well as a "custom" server (service?).

Jakob Gade
I'm a noob to this, so I am not equipped to make an informed choice one over another. HOwever, when I read about WCF services, they seem to be a .NET 4 feature. I am tied down by being forced to use .NET 2.0 only.
brainydexter
Start out with an HttpHandler, they're simple and fast, and really not any different than implementing an .aspx page.
Jakob Gade
A: 

Why don't you use Web Service hosted at a server.It can be used in .Net 2.0 and serves all the functionality , you mentioned.

saurabh
I thought of it, but sending stuff in a custom message request and response is really throwing me off. I am not sure how I would do that using web services ?
brainydexter
I have a question about using web services. Is it possible to return the response of a web service call with something else other than XML ? In this case I'd like to send the custom response message
brainydexter