호우동의 개발일지

Today :

article thumbnail
[C#] 소켓(Socket) 서버(Server) & 클라이언트(Client) 통신 간단한 구현
C#/Game Server 2023. 5. 20. 22:43

서버 DNS 및 Socket 연결 string host = Dns.GetHostName(); IPHostEntry ipHost = Dns.GetHostEntry(host); IPAddress address = ipHost.AddressList[0]; IPEndPoint ipEndPoint = new IPEndPoint(address, 7777); // 최종주소 Socket socket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); socket.Connect(ipEndPoint); // 해당 ip주소로 연결 요청 Console.WriteLine($"Connect To {socket.RemoteEndPoint.ToSt..