1. 程式人生 > >C# Socket程式設計之繫結IP與埠

C# Socket程式設計之繫結IP與埠

 Socket serverSocket=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);  //獲取Socket

            IPAddress ipAddress=IPAddress.Parse("192.168.0.109");   //繫結IP

            

IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 891);  //繫結埠

            serverSocket.Bind(ipEndPoint);//繫結IP和埠號

 

下一章:S# Socket程式設計之傳送訊息與接收訊息