2 qq 18505197 qq_18505197 于 2014.08.31 11:45 提问

C# Httplistener 外网无法连接

外网ip无法连接到Httplistener(已经端口映射),但是内网可以比如 192.168.1.101:8080。用nodejs可以从外网连接,不知道是怎么回事.

public TCHttp(string hostname)
{
HttpListener httpListener = new HttpListener();
httpListener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
httpListener.Prefixes.Add("http://+:8080/");
httpListener.Start();
httpListener.BeginGetContext(GetContextCallback, httpListener);

return;
}
private void GetContextCallback(IAsyncResult ar)
{
HttpListener httpListener = ar.AsyncState as HttpListener;
HttpListenerContext listenerContext = httpListener.EndGetContext(ar);
httpListener.BeginGetContext(GetContextCallback, httpListener);
using (StreamWriter responseWriter = new StreamWriter(listenerContext.Response.OutputStream))
{
OnReceiveHttpContext(listenerContext, responseWriter);
responseWriter.Close();
}
listenerContext.Response.Close();
}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!