Writing a server in C# .NET to handle custom requests/response
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 开发者_C百科a request in this custom format ?
I'd appreciate any help with this.
Thanks
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.
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?).
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.
精彩评论