Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Error Message.

Discussion in 'Scripting' started by larswik, Jun 10, 2018.

  1. larswik

    larswik

    Joined:
    Dec 20, 2012
    Posts:
    312
    Hello, working on adding network ability to my game and I have run in to a problem following a tutorial on line. I think the error message is more generic and I am missing something simple. video was posted October 2016 so some things might have changed?

    Error.
    The error is happening on the if(c != null && ... && ...).

    Code (CSharp):
    1. bool IsConnected(TcpClient c){
    2.         try
    3.         {
    4.             if(c != null && c.Client != null && c.Client.Connect)
    5.             {
    6.                 if (c.Client.Poll(0, SelectMode.SelectRead))
    7.                 {
    8.                     return !(c.Client.Receive(new byte[1], SocketFlags.Peek) == 0);
    9.                 }
    10.                 return true;
    11.             }
    12.             else{
    13.                 return false;
    14.             }
    15.         }
    16.         catch
    17.         {
    18.             return false;
    19.         }
    20.     }
    I took a screen shot from the Tut video and I have gone over it line by line.
     

    Attached Files:

  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Well...they have C.Client.Connected
    You have C.Client.Connet

    My guess is Connet is a method call and Connected is a bool to determine if you are connected.
     
  3. larswik

    larswik

    Joined:
    Dec 20, 2012
    Posts:
    312
    OMG Thank you so much Brathnann. 4 hours of looking over the code and missed this typo. The errors went away now and I can continue.