gnopaste

Sorry for this ugly message. We are searching for some translators.
Please send me an eMail or jabber: t4c@im.digital-bit.ch
Got: de, en, pl, ro, lu, ru, es - Need: everything else

Name
Anonymous
Scriptlanguage
C++
Tabwidth
4
Date
11/05/2009 08:11:09 pm
IP
85.177.202.204

The user was too lazy to give a description

  1. bool HonProto::connect()
  2. {
  3.     NETLIBOPENCONNECTION ncon = { 0 };
  4.     ncon.cbSize = sizeof(ncon);
  5.     ncon.szHost = "127.0.0.1";//account.chatUrl.c_str();
  6.     ncon.wPort = HON_CHAT_PORT;
  7.     m_con = (HANDLE) CallService( MS_NETLIB_OPENCONNECTION, (WPARAM) m_hNetlib, (LPARAM) & ncon);
  8.     if (!m_con)
  9.     {
  10.         // error TODO: talk to the user
  11.         return false;
  12.     }
  13.     m_pcon = (HANDLE) CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM) m_con, 1024*4);
  14.     if (m_pcon == NULL) {
  15.         // Connection Error TODO: Hint!
  16.         return false;
  17.     }
  18.  
  19.     // start receiving messages from host
  20.     honFork( &HonProto::ThreadProc, NULL );
  21.     Sleep( 100 );
  22.     return m_con != NULL;
  23. }
  24.  
  25. void __cdecl HonProto::ThreadProc( void* )
  26. {
  27.     doReceive();
  28. }
  29.  
  30. void HonProto::doReceive()
  31. {
  32.     char chBuf[1024*4+1];
  33.     int cbInBuf = 0;
  34.     int iBufLen = 0;
  35.  
  36.     if (NLSend("HELP\n", 7) == SOCKET_ERROR)
  37.         OutputDebugString(_T("FEJLER"));
  38.     NLSend("HELP2323\n", 11);
  39.  
  40.     while( m_con && m_pcon )
  41.     {
  42.         NETLIBPACKETRECVER nlpr = { 0 };
  43.         nlpr.cbSize = sizeof(NETLIBPACKETRECVER);
  44.         nlpr.dwTimeout = INFINITE;
  45.         nlpr.bufferSize = 1024*4;
  46.         iBufLen = (int) CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM) m_pcon, (LPARAM) &nlpr);
  47.         if (iBufLen == 0)
  48.             break;
  49.         parsePacket(nlpr.buffer, iBufLen);
  50.         // what about the ACKS that don't contain data?
  51.     }
  52.  
  53.     if ( m_con ) {
  54.         Netlib_CloseHandle(m_con);
  55.         m_con = NULL;
  56.     }
  57.  
  58. }
submitter » gnopaster | imprint « imprint     
» Terms of use «
» digital bit dot ch - t4c's new home «