Click here to Skip to main content
15,911,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
transoft3-Feb-12 6:02
transoft3-Feb-12 6:02 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
SledgeHammer013-Feb-12 14:14
SledgeHammer013-Feb-12 14:14 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
transoft4-Feb-12 4:34
transoft4-Feb-12 4:34 
GeneralRe: "InvalidateRect" leaves dirty on screen PinPopular
SledgeHammer014-Feb-12 7:49
SledgeHammer014-Feb-12 7:49 
GeneralRe: "InvalidateRect" leaves dirty on screen Pin
MikeTHennessy7-Feb-12 12:10
MikeTHennessy7-Feb-12 12:10 
QuestionCAsynSocket connection problem Pin
ForNow2-Feb-12 16:03
ForNow2-Feb-12 16:03 
AnswerRe: CAsynSocket connection problem Pin
«_Superman_»2-Feb-12 18:07
professional«_Superman_»2-Feb-12 18:07 
GeneralRe: CAsynSocket connection problem Pin
ForNow2-Feb-12 18:49
ForNow2-Feb-12 18:49 
My CAsynsocket clas lives whitin a CWIinThread Class
class SockCLeintThread : public CWinThread {
public:
DECLARE_DYNCREATE(SockCLeintThread)
// DECLARE_DYNAMIC(SockCLeintThread)
// IMPLEMENT_DYNAMIC(SockCLientThread)
public:
CWnd *sendwindow;
CWnd *call_wnd;
CString buffer;
char thread_id[15];;
SockClient thisocket; // Socket to do ocommunication
virtual BOOL InitInstance(); // Just for starters
virtual int Run(); // keep on moving
// virtual int ExitInstance();
void receive_work(WPARAM , LPARAM);
void Sendit(WPARAM, LPARAM);
void Receiveit(WPARAM, LPARAM);
void sockoper(WPARAM, LPARAM);
LPCTSTR ipaddr;
UINT port;
BOOL idle; // looking for work
SockCLeintThread();
~SockCLeintThread();
struct {
unsigned int is_connected : 1;
} flags;

protected:
DECLARE_MESSAGE_MAP()

};

My CASynsocket defination

C#
class SockClient : public CAsyncSocket
{
 public:
      // SockCleint(char *sockptr);
        SockClient();
        char *sockbuffer;       // send and receive buffer
        int num_buff;
        CWnd *send_wnd;
        int thread_no;
   protected:
                         // window to send message to
        virtual void OnReceive(int nErrorCode);
        virtual void OnSend(int nErrorCode);
        virtual void OnConnect(int nErrorCode);
        virtual void OnClose(int nErrorCode);


};



In the initinstance for the CWinThread I do a create a get a good return code "1" howver for the connect I get a 0 GetLastError return
VB
WSAEWOULDBLOCK
10035


C#
OOL SockCLeintThread::InitInstance()
   {
int error_code;
CHERC_CMDApp* main_app;


            main_app = (CHERC_CMDApp *)AfxGetApp();



       SockCLeintThread* current = dynamic_cast<SockCLeintThread*>(current);

           SetThreadName(m_nThreadID,thread_id);

         if(thisocket.Create(port,SOCK_STREAM,FD_READ|FD_WRITE|FD_CONNECT,NULL)== 0)
         {
                         error_code =  thisocket.GetLastError();
                  }

    //                  thisocket.AsyncSelectFD_READ|FD_WRITE|FD_CONNECT|FD_CLOSE);  //REQUEST NOTIFICATION

                  

          main_app = (CHERC_CMDApp *)AfxGetApp();


          if( thisocket.Connect(ipaddr,port) == 0)
                  {
                         error_code =  thisocket.GetLastError();
                  }
           else
              current->flags.is_connected = 1;





    return TRUE;                                                   // [11]
   }



here is my ::OnConnect overridable
C#
void SockClient :: OnConnect(int nErrorcode)
  {

      CHERC_CMDApp* main_app;

            main_app = (CHERC_CMDApp *)AfxGetApp();

    //   SockCLeintThread* current;
       SockCLeintThread* current = dynamic_cast<SockCLeintThread*>(current);
      current = (SockCLeintThread*)AfxGetThread();
       UNREFERENCED_PARAMETER(nErrorcode);
          CAsyncSocket::OnConnect(nErrorcode);
       current->flags.is_connected = 1;
  //    if(nErrorcode == WSAETIMEDOUT)
    //    Connect(current->ipaddr,current->port);

        AsyncSelect(FD_WRITE);
   //    main_app->pevent->SetEvent();
  }


Thanks
AnswerRe: CAsynSocket connection problem Pin
pyunwang2-Feb-12 19:00
pyunwang2-Feb-12 19:00 
GeneralRe: CAsynSocket connection problem Pin
ForNow2-Feb-12 19:59
ForNow2-Feb-12 19:59 
QuestionSimple Asymetric Encryption Pin
Bram van Kampen2-Feb-12 14:23
Bram van Kampen2-Feb-12 14:23 
AnswerRe: Simple Asymetric Encryption Pin
Chris Losinger5-Feb-12 5:07
professionalChris Losinger5-Feb-12 5:07 
QuestionHow to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 4:59
Stefan_Lang2-Feb-12 4:59 
QuestionRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
David Crow2-Feb-12 5:29
David Crow2-Feb-12 5:29 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 6:10
Stefan_Lang2-Feb-12 6:10 
QuestionRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
David Crow2-Feb-12 9:21
David Crow2-Feb-12 9:21 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 22:14
Stefan_Lang2-Feb-12 22:14 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
jschell2-Feb-12 8:39
jschell2-Feb-12 8:39 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 21:56
Stefan_Lang2-Feb-12 21:56 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
jschell3-Feb-12 10:23
jschell3-Feb-12 10:23 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang6-Feb-12 5:53
Stefan_Lang6-Feb-12 5:53 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Bram van Kampen3-Feb-12 16:00
Bram van Kampen3-Feb-12 16:00 
AnswerRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Bram van Kampen2-Feb-12 14:06
Bram van Kampen2-Feb-12 14:06 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Stefan_Lang2-Feb-12 22:22
Stefan_Lang2-Feb-12 22:22 
GeneralRe: How to maintain an external C++ DLL developed with Literate Programming? Pin
Bram van Kampen3-Feb-12 15:22
Bram van Kampen3-Feb-12 15:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.