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\$
  • \$\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\$ – Doctor Niklas Oct 21 '16 at 12:57
  • \$\begingroup\$ some times the user may press the connects the button twice.in that case \$\endgroup\$ – user1509674 Oct 21 '16 at 13:13
  • \$\begingroup\$ @DoctorNiklas : when I take the desktop build of the app,its not getting connected to server \$\endgroup\$ – user1509674 Oct 21 '16 at 13:19
  • \$\begingroup\$ Any logs on the server? Also wireshark should show you what's happening \$\endgroup\$ – PompeyPaul Oct 21 '16 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\$ – user1509674 Oct 24 '16 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.