I am having trouble as I am trying to run my clientsocket.connect until a connection has been established. However it is not running my connect method and I cannot seem to be able to diagnose why that is

 private static ClientSocket clientSocket = new ClientSocket();
        private delegate void connection();

        public Form1()
            connection waitConnect = callConnect;
            Console.WriteLine("before callconnect invoke");
            IAsyncResult asyncConnect = waitConnect.BeginInvoke(null, null);
            Console.WriteLine("Main method now has control");

        private void callConnect()
            while (!clientSocket.connected)
                Console.WriteLine("still connecting...");
                clientSocket.connect("", 43);

clientsocket.connected checks a connection has been established.
If more information is needed I can provide.

Thank you

Recommended Answers

All 3 Replies

does this also work if the server isnt running?

use a background worker, Don't use thread.sleep this will hold off your operation.
good luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.