Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 507363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:47:47+00:00 2026-05-13T06:47:47+00:00

I am creating a little game client that will end up connecting to a

  • 0

I am creating a little game client that will end up connecting to a server to gather some information on available games to play, how many players are playing, and all kinds of other stuff that you can imagine it ought to do.

My difficulties come in finding an effective way in dealing with the connect/retry connect sequence upon first loading.

I imagined my client would follow this process in trying to connect:

  1. Client application executed
  2. Try to establish connection
  3. If connection successful gather information – If not successful proceed to step 4
  4. Display a new dialog/form that prompts the user that a connection is trying to be established
  5. Loop till a connection has been established

I have been questioning my methods in trying to follow this sequence. I question if it is the right/most effective way to connect as well as to why my form I display in step 4 isn’t working?

try
{
    sock.Connect(authenServerEP);
    // Once connected show our main client window
    this.Show();
    // Create the LoginForm once a connection has been established and display
    LoginForm loginForm = new LoginForm();
    loginForm.ShowDialog();
    if (false == loginForm.Visible)
    {
        loginForm.Dispose();
    }
}
catch (SocketException firstConnectException)
{
    // Load retrying connection form
    EstablishingConnectionForm establishingConnectionForm = new EstablishingConnectionForm();                                
    establishingConnectionForm.Show();

    bool connected = false;
    // Loop until we are connected
    while (!connected)
    {
        try
        {
            sock.Connect(authenServerEP);
            connected = true;
            establishingConnectionForm.Dispose();
         }
         catch (SocketException retryConnectException)
         {
             // Pass and retry connection
         }
     }
} // end catch (SocketException firstConnectException)   

As you can see I am catching the SocketException that is raised when there is a problem connecting to the server (such as the server isn’t running). I then go on to try to continuously loop till a connection is established. I dunno if I ought to be doing it this way. Are there better ways to do this?

Also when I display establishingConnectionForm with Show() it doesn’t look like it all of the forms/tools initialize (initialize could be misleading). The Label that is on the form is just shaded out in white as opposed to having its text displayed. Not only that but it seems like I can’t select the form/dialog and actually move it around. It sits there with the “Thinking/Working” mouse icon. Now I presume this is because I am looping trying to reconnect and its blocking because of this (I could be wrong on the blocking?). Can this problem be solved with multithreading? If so do I need to multithread? Is there an easier way to show my form/dialog and be able to interact (IE movie it around and close it with the ‘X’ in the upper right corner) with it while I still try to reconnect?

Thanks a bunch. I really appreciate you reading this post and am grateful for this community. 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:47:48+00:00Added an answer on May 13, 2026 at 6:47 am

    Just an example below where I would handle any continuation logic in the catch and either break out or continue inside the while loop.

    Andrew

    while (!connected)
    {
        try
        {
            sock.Connect(authenServerEP);
            connected = true;
            establishingConnectionForm.Dispose();
        }
        catch (SocketException retryConnectException)
        {
            //Optional - add some wait time may be 5 seconds i.e. "trying again in 5 seconds"
            //System.Threading.Thread.Sleep(5000);
            //Here check the number of attempts and if exceeded:
            if(numberOfTimes == 5)
            {
                break;
            }
            else
            {
                numberOfTimes++; 
                continue;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a little flash game for the facebook platform, but I am
I'm creating a little puzzle game just as a hobby project but the project
I am creating an little hobby database driven browser based game and I stumbled
I am creating a little map app where you are given information, video and
I am creating a little testing component and am running into a problem Basically
I've got the following in my .css file creating a little image next to
A little background: I'm creating a set of adapters to allow communication with mobile
I just started thinking about creating/customizing a web crawler today, and know very little
In my little scratch built flex game framework, I have defined a class called
I'm working on a C# Server application for a game engine I'm writing in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.