private ConnectServer ( string host, int port ) : void | ||
host | string | |
port | int | |
Результат | void |
public void StartConnect() { string ip = Singleton <ServiceModel> .GetInstance().GetCurSeverInfo().IP; int port = Singleton <ServiceModel> .GetInstance().GetCurSeverInfo().Port; client.ConnectServer(ip, port); }
public void IniClient() { client = new SocketClient(); client.ServerConnected += Client_ServerConnected; client.ServerConnectedException += Client_ServerConnectedException; client.ServerDisconnected += Client_ServerDisconnected; client.DataReceived += Client_DataReceived; client.WriteException += Client_WriteException; client.ConnectServer("127.0.0.1", 6666); }
/// <summary> /// connect to the server /// </summary> public void ConnectServer() { IPAddress ipAddress; if (!IPAddress.TryParse(Config.Instance.ServerIP, out ipAddress) || Config.Instance.TcpPort < 0 || Config.Instance.TcpPort > 65535) { Debug.LogError("ip or port is wrong!"); return; } client.ConnectServer(Config.Instance.ServerIP, Config.Instance.TcpPort); }
/// <summary> /// 发送链接请求 /// </summary> public void SendConnect(string host, string port) { _socket.ConnectServer(host, port); StartCoroutine(ConnectTimeOut(host, port)); //设置超时连接 }
// 开启网络连接 public void startConnect(string ip, int port) { client.ConnectServer(ip, port); }