Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Connect status = 0, but sending messages

Posted on 2003-02-28
Medium Priority
Last Modified: 2013-11-20
Well, here is a code fragment that is working.. I wonder why??

     // Connect to the server on port 9090
     connection_status = this->client_socket->Connect( ip, 9090 );

     if( connection_status )
          println( "Connection to server successful" );
          // Get the errors for the connect operation
          int lastErrorCode = this->client_socket->GetLastError();

          //if( WSAEWOULDBLOCK != lastErrorCode )
          //     this->getConnectError( lastErrorCode );

          // Format the message to read
          // "This is message from thread : <threadname>"
          this->message = (char*)malloc(200 + this->threadName.GetLength());
          strcpy(this->message, "This is message from thread : This is message from thread : This is message from thread : This is message from thread : ");
          strcat(this->message, this->threadName);
          strcat( message, "\r\n" );

          // send infinitely this message
          for( this->message_id = 0;; this->message_id++)
               this->sendMessage( message );
Question by:gkasinath

Expert Comment

ID: 8144461
I believe Connect always fails due to its blocking nature, even in Async sockets. You may need to override the OnConnect function and do your connection status stuff there. Thats the only real place to accurately determine a valid connection.

Accepted Solution

modulo earned 0 total points
ID: 11812330
PAQed - no points refunded (of 50)

Community Support Moderator

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question