一.(测试时,应该先开启服务器)
Server类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
namespace Server
{
class Server
{
static void Main(string[] args)
{
Console.WriteLine("Server is runing... ...");
//获取本地ip
//IPAddress iP = new IPAddress(new byte[] { 10,50,6,164 });
//默认可能就是127.0.0.1,其他的不行---------?
IPAddress iP = IPAddress.Parse("127.0.0.1");
//IPAddress iP = Dns.GetHostEntry("localhost").AddressList[0];
TcpListener listener = new TcpListener(iP, 8500);
//开始监听
listener.Start();
Console.WriteLine("Start Listening... ...");
TcpClient remoteClient = listener.AcceptTcpClient(