0

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()
        {
            InitializeComponent();
            connection waitConnect = callConnect;
            Console.WriteLine("before callconnect invoke");
            IAsyncResult asyncConnect = waitConnect.BeginInvoke(null, null);
            Console.WriteLine("Main method now has control");
            waitConnect.EndInvoke(asyncConnect);
        }



        private void callConnect()
        {
            while (!clientSocket.connected)
            {
                Thread.Sleep(1000);
                Console.WriteLine("still connecting...");
                clientSocket.connect("127.0.0.1", 43);
            }
        }

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

Thank you

3
Contributors
3
Replies
12
Views
3 Years
Discussion Span
Last Post by oussama_1
0

does this also work if the server isnt running?

Edited by Johnathon332

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.