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 6537845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:39:55+00:00 2026-05-25T10:39:55+00:00

i am creating client sever application in windows using socket and i want to

  • 0

i am creating client sever application in windows using socket and i want to throw exception at run time from thread if any problem occur but i am getting error for throw statement.

    //create thread in cpp file
    CreateThread(NULL,0,startServer,this,0,NULL);

        //thread in header file
            static unsigned long __stdcall startServer(void *i_SocketTransportServer)
           {
                           ((SocketTransportServer*)i_SocketTransportServer)->StartServerThread(((SocketTransportServer *)i_SocketTransportServer)->m_socketServer);
                return 0;
           }

        //and StartServerThread is function called by thread
         // SocketTransportServer is inner class of  RMLThinTransport
            void RMLThinTransport::SocketTransportServer::StartServerThread(SOCKET i_socketServer)
            {
                m_socketAccept=NULL;
                while(true)
                {
                    Sleep(20);
                    if(m_canAcceptMore)
                    {
                        m_canAcceptMore=false;
                        if(!m_isRunning)
                        {
                                break;
                        }
                        try
                        {
                            m_socketAccept=accept(m_socketServer,NULL,NULL);
                            if(m_socketAccept==INVALID_SOCKET)
                            {
                                int lastError=WSAGetLastError();
                                closesocket(m_socketAccept);
                                                                                                                            SocketExceptions                                        
 exceptionInAcceptAtServer;
                                  exceptionInAcceptAtServer.detectErrorAccept(&lastError);

throw exceptionInAcceptAtServer;
                            }
                            else
                            {
                                //_LOG("Client connected",EventTypeInfo) ;
                                OutputDebugStringW(L"client connected.....");
                                /* If client connected then setClinetCout value 1 */
                                setClientCount(1);
                                m_ClientSockets.push_back(m_socketAccept);
                                CreateThread(NULL,0,receiveDataAtServer,this,0,NULL);
                            }

                        }
                        catch(SocketExceptions& i_exceptionInAcceptAtServer)
                        {   

                            /*OutputDebugStringW(L"Can't accept client In Exception. ."); */
    throw i_exceptionInAcceptAtServer;//getting runtime error from here

                        }
                    }

                }

            }

now i want to throw error when server close but i am getting run time error. so is there any way so i can get error in my main function.sorry but i am new in c++ so please help me. and error is

enter image description here

  • 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-25T10:39:55+00:00Added an answer on May 25, 2026 at 10:39 am

    The code that throws the exception is not the problem; it’s the lack of any code to catch the exception that’s the problem. The application is terminating because nothing is catching the exception you’re throwing; you must ensure that something is going to catch it. Your startServer method — the thread procedure — must catch the exception, and cleanly exit the thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been creating a an application with C# using W2k8+IIS7/SQLExpress 2008/Web Service/Windows Client. I'll
I'm creating an installer for my Windows client application. Currently I create an MSI
I am creating server-client application for iPhone. I want to communicate between two application
I'm creating a client application that connects to MS SQL Sever via ADO.NET. I
I'm creating a Windows application which reads XML file from given server. This application
I'm creating a client-server application which communicates via a custom socket protocol. I'd like
I am creating a client server application using c sharp. The server is using
I am using creating a server/client style program, and it uses tcp connections. Now,
I am creating a desktop/client application that will be installed on +/- 5 PCs,
I am creating a web based email client using c# asp.net. What is confusing

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.