日期:2014-05-20 浏览次数:21109 次
this._sockOfRecv = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.IP); this._sockOfRecv.Bind(this._localPoint);
static void Main(string[] args) { int Port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Port"]); int length; byte[] bytes = new byte[32768]; string str = string.Empty; Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //参数1指定本机IP地址(此处指所有可用的IP地址),参数2指定接收用的端口 IPEndPoint myHost = new IPEndPoint(IPAddress.Any, Port); //将本机IP地址和端口与套接字绑定,为接收做准备 socket.Bind(myHost); }