System.Net.Sockets.SocketException:“以一种访问权限不允许的方式做了一个访问套接字的尝试。”

qq_35305161 2017-07-05 10:39:13
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Net;
using System.Net.Sockets;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//IPAddress ip = new IPAddress(new byte[] { 127, 0, 0, 1 });
IPAddress ip = IPAddress.Parse("127.0.0.1");
//IPAddress ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];

TcpListener tlistener = new TcpListener(ip, 1433);
tlistener.Start();
Console.WriteLine("服务器监听启动......");
while (true)//看上去是死循环,由于阻塞方法,大部分时间都在等待
{
TcpClient remoteClient = tlistener.AcceptTcpClient();//接收已连接的客户端,阻塞方法
Console.WriteLine("客户端已连接!local:{0}<---Client:{1}", remoteClient.Client.LocalEndPoint, remoteClient.Client.RemoteEndPoint);
}

//ConsoleKey key;
//do
//{
// key = Console.ReadKey(true).Key;
//}
//while (key != ConsoleKey.Q);
}
}
}
...全文
1672 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
TonyTonyQ 2017-07-06
  • 打赏
  • 举报
回复 1
你本机是否安装了SQL Server? 1433是SQL Server的监听端口,估计是端口冲突导致错误。
qq_35305161 2017-07-05
  • 打赏
  • 举报
回复
到底是怎么回事啊?有没有大佬教教我!

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧