Exemplo n.º 1
0
 public void ReStartTcpSocket(ConnectDelegate1 _connectback)
 {
     Log.Debug("打开一个tcp连接StartTcpSocket");
     if (client == null)
     {
         client = new SocketLayer();
     }
     else
     {
         Close(false);
     }
     connectBack  = null;
     connectBack1 = _connectback;
     client.SetConnectCallback(ConnectBack);
     proto    = new CProto();
     recvBuf  = new byte[BUFFER_SIZE * 64];
     recvLen  = 0;
     pingByte = new byte[] { (byte)CProto.PType.ping };
     client.Connect(_host, _port);
 }
Exemplo n.º 2
0
 public void StartTcpSocket(string host, int port, SocketName name, ConnectDelegate _connectback)
 {
     Log.Debug("打开一个tcp连接StartTcpSocket");
     _host = host;
     _port = port;
     if (client == null)
     {
         client = new SocketLayer();
     }
     else
     {
         Close(true);
     }
     socketName   = name;
     connectBack  = _connectback;
     connectBack1 = null;
     client.SetConnectCallback(ConnectBack);
     proto    = new CProto();
     recvBuf  = new byte[BUFFER_SIZE * 64];
     recvLen  = 0;
     pingByte = new byte[] { (byte)CProto.PType.ping };
     client.Connect(host, port);
 }