?
Solved

Connect status = 0, but sending messages

Posted on 2003-02-28
4
Medium Priority
?
148 Views
Last Modified: 2013-11-20
Hi!
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" );
     else
     {
          // 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 );
          }
     }
Regds
Lupo
0
Comment
Question by:gkasinath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:DigitalQ
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.
0
 

Accepted Solution

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

modulo
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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