使用带有套接字的c#控制台服务器和一个html页面(客户端)从中获取
发布时间:2020-12-15 21:41:10 所属栏目:百科 来源:网络整理
导读:I’m writing a c# changing password page. I haven’t done much Socket programming,and I am not sure the best way to go about it. 必须有控制台应用程序(服务器)和带有以下文本框的html页面(客户端): Username [_______]Old password [______]New pa
必须有控制台应用程序(服务器)和带有以下文本框的html页面(客户端): Username [_______] Old password [______] New password [______] [Submit] 当用户点击提交然后,将创建一个新线程,我正在检查信息是否良好并且某些功能将被执行. 这应该接受来自定义端口上的多个客户端的连接. 我怎样才能做到这一点? 到目前为止我所做的是: 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 } } 但我不知道如何制作html页面,我将信息发送到服务器并使用它们. 解决方法
在原始套接字上实现自己的HTTP协议将是一项相当大的任务.您可以使用Mono XSP嵌入可以将ASP.NET页面提供给应用程序的Web服务器,或者您可以使用HttpListener:
http://msdn.microsoft.com/en-us/library/system.net.httplistener(v=vs.100).aspx (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |