using System;
using System.Net;
using System.IO;
using System.Threading;
using System.Text;
using MySql.Data.MySqlClient;
using System.Collections.Generic;
public class TheServer
{
private string result = "";
private MySqlConnection conn;
private HttpListener _listener;
private Thread _threadWatchPort;
private DataBaceTool Tool = new DataBaceTool();
// private List<Dictionary<string, object>> Listinfo;
static void Main(String[] args)
{
if (!HttpListener.IsSupported)
{
Console.Write("系统不支持HttpListener");
}
else
{
Console.Write("系统支持HttpListener");
}
TheServer Start = new TheServer();
Start.StartListening();//开始监听
Start.Tool.OpenDataBace();//打开数据库
// Start.QueryAllData("AirportManager");
}//检测系统支持不支持
public void StartListening()
{
Console.Write("开始监听" );
_listener = new HttpListener();
_listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
_listener.Prefixes.Add("http://+:8080/");
_listener.Start(); //开始监听端口,接收客户端请求
_threadWatchPort = new Thread(WatchPort);
_threadWatchPort.Start();
Console.Write("开启了端口
使用HttpListener 实现简单的web服务器
最新推荐文章于 2024-02-17 17:11:34 发布