using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; namespace Server_Dashboard_Socket { /// /// Client Socket /// /// The Protocol type, either JsonMessageProtocol or XmlMessageProtocol /// The message type, either JObject or XDocument public class ClientChannel : SocketChannel where TProtocol : Protocol, new() { /// /// Connect to the socket async /// /// An endpoint with an IP address and port /// public async Task ConnectAsync(IPEndPoint endpoint) { //Creates a new Socket var socket = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); //Connects to the socket await socket.ConnectAsync(endpoint).ConfigureAwait(false); //Attach the socket to a network stream Attach(socket); } } }