1
\$\begingroup\$

I have a button, when I press the connect button, it gets connected to the server. When I press the connect button again, it's getting delay in connecting to the server. Below is the code to connect to the server:

public void setupSocket() {
    try {
        socket = new Client(Host, Port);
        theStream = socket.GetStream();
        theWriter = new StreamWriter(theStream);
        theReader = new StreamReader(theStream);
        socketConnect = true;
    }
    catch (Exception e) {
        Debug.Log("Socket error:" + e);
    }
}

And I have one more issue. When I take the desktop build of the app and opened the app, clicked button, it's getting connected to the server, but when I click the button again it's not getting connected. But when I close the app, it displays the connection message and also close message on the server. Is there anything to be set when taking the desktop build?

Can anybody help out what will be the problem?

\$\endgroup\$
5
  • \$\begingroup\$ Why would you want to press the Connect button twice? That makes no sense, check the socketConnect boolean and only connect if it is false. \$\endgroup\$ Commented Oct 21, 2016 at 12:57
  • \$\begingroup\$ some times the user may press the connects the button twice.in that case \$\endgroup\$ Commented Oct 21, 2016 at 13:13
  • \$\begingroup\$ @DoctorNiklas : when I take the desktop build of the app,its not getting connected to server \$\endgroup\$ Commented Oct 21, 2016 at 13:19
  • \$\begingroup\$ Any logs on the server? Also wireshark should show you what's happening \$\endgroup\$ Commented Oct 21, 2016 at 15:55
  • \$\begingroup\$ yes.When I disconnect the client part its still showing the "Listening to 0.0.0.0" on the server.Why is that?Is that any problem with my server part \$\endgroup\$ Commented Oct 24, 2016 at 3:44

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.