C# Socket通信
PS:也是在网上查找的各位大神的代码进行理解,如有侵犯,请通知删除
效果:
服务端代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
using System.Net.Sockets;
namespace ServerCtrl
{
class Program
{
public void ServerStart()
{
Socket Server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint EndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5200);
Server.Bind(EndPoint);
Server.Listen(2)