Using a C # console server with sockets and an html page (client) to receive information from it

I am writing a C # password change page. I have not done a lot of socket programming, and I'm not sure if this is the best way.

There should be a console application (server) and an html page (client) with the following text fields:

Username [_______] Old password [______] New password [______] [Submit] 

When the user clicks the "Submit" button, then a new stream will be created, where I will check if the information is good and some functions will be performed.

This should accept connections from multiple clients on a specific port.

How can i do this?

What i have done so far:

  public static TcpListener Listener; public static int Port = 8080; static void Main(string[] args) { IniFile FPth = new IniFile(@"D:\ServerInfo.ini"); ServerPort = int.Parse(FPth.IniReadValue("ConnectionINFO", "ServerPort")); Listener = new TcpListener(IPAddress.Any, Port); Listener.Start(); Thread NewThread = new Thread(new ThreadStart(ChangingINFO)); ChangingINFO(); Console.WriteLine("Server is ONLINE."); } static ChangingINFO() { while (true) { Socket Sockt = Listener.AcceptSocket(); try { if (Sockt.Connected) { //Here I should get the information from the client on submit. //But I don't know how } } 

But I do not know how to create an html page where I send information to the server and work with them.

+4
source share
1 answer

Implementing your own HTTP protocol on top of the source sockets will be quite a big deal. You can use Mono XSP to embed a web server that can serve ASP.NET pages in your application, or you can use the HttpListener instead:

http://msdn.microsoft.com/en-us/library/system.net.httplistener(v=vs.100).aspx

+1
source

Source: https://habr.com/ru/post/1439229/


All Articles