Ejemplo n.º 1
0
    //Function: InitConnection()
    //Argument: string
    //Argument: int
    //Purpose:  This function initates the connection to the server.
    public int InitConnection(string t_ip, int t_port)
    {
        if (!TestConnectivity())
        {
            IPAddress serverAddr = IPAddress.Parse(t_ip);
            IPEndPoint serverEP = new IPEndPoint(serverAddr, t_port);
            //Connect to Game Server
            m_sock.Connect(serverEP);
            m_sock.Blocking = false;
            m_writer = new BufferedWriter();
            m_reader = new BufferedReader();

            m_writer.Init(4096);
            m_reader.Init(4096);
            return 0;
        }
        Debug.Log("Socket already connected.. please pay attention!\n");
        return -1;
    }