ClientScript.closeSocket C# (CSharp) Method

closeSocket() public method

public closeSocket ( ) : void
return void
    public void closeSocket()
    {
        if (!ready)
        {
            Debug.Log("Could not close socket as it was not ready.");
            return;
        }
        writer.Close();
        reader.Close();
        socket.Close();
        ready = false;
    }

Usage Example

    private void StartGameLoop()
    {

        cs = GameObject.Find("ClientScript").GetComponentInChildren<ClientScript>();
        //WWW results = cs.GET("http://answers.unity3d.com/questions/208309/get-request-wrapper.html");
        // Debug.Log(results.text);
        //depending on the data we are polling, we will be making different get requests

        //  var N = JSON.Parse(results.text);

        //two get requests -> one to request for new names to sacrifice and one for a status check and confirmation to the server
        Debug.Log("Starting TCP socket connection");
        cs.socketInit();
        // cs.writeSocket("test!");

            String str = cs.readSocket();
            while (str == null)
            {
                Debug.Log("str is null");
                str = cs.readSocket();
            }
            Debug.Log(str);
        
        cs.closeSocket();
    }