Click here to Skip to main content
15,887,356 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem displaying CStatic text item Pin
jeron11-Jul-15 11:32
jeron11-Jul-15 11:32 
GeneralRe: Problem displaying CStatic text item Pin
ForNow1-Jul-15 12:19
ForNow1-Jul-15 12:19 
GeneralRe: Problem displaying CStatic text item Pin
ForNow2-Jul-15 13:27
ForNow2-Jul-15 13:27 
Questionrecv no blocking Pin
mosine29-Jun-15 21:33
mosine29-Jun-15 21:33 
AnswerRe: recv no blocking Pin
CPallini29-Jun-15 21:54
mveCPallini29-Jun-15 21:54 
GeneralRe: recv no blocking Pin
mosine29-Jun-15 22:21
mosine29-Jun-15 22:21 
GeneralRe: recv no blocking Pin
CPallini29-Jun-15 22:35
mveCPallini29-Jun-15 22:35 
GeneralRe: recv no blocking Pin
mosine29-Jun-15 22:52
mosine29-Jun-15 22:52 
I post my code:
C
DWORD  WINAPI cliTh1( LPVOID lpData ){
    struct CLIENT_INFO *pClientInfo;
    char szClientMsg[250];
    char packet[50];
    HANDLE clientTxThread;

    pClientInfo = (struct CLIENT_INFO *)lpData ;
    char *ip = inet_ntoa(pClientInfo->clientAddr.sin_addr);
    printf("SOCKET:%d  - IP:%s  - THREAD_ID:%ld\n", pClientInfo->hClientSocket, ip   
                                                   ,GetCurrentThreadId());
    Q->pClient = pClientInfo;
    pClientInfo->primaConn = 0;
    pClientInfo->indirizzo = 0;
    pClientInfo->p = getDisconnect;
    while ( 1 ){
        if(j>=MAXELEMENTS){j=0;};
        if(WSAGetLastError()){
            if(pClientInfo->primaConn == 1){
                disconnectBuffer[pClientInfo->indirizzo] = 1;
                pClientInfo->primaConn=0;
            }
            if(disconnectBuffer[pClientInfo->indirizzo] == 1){
                creaPackDisc(packet, pClientInfo->indirizzo);
                strcpy(bufferRx[j].packet, packet);
                Enqueue(Q,  packet);
                j++;
            }else{
                closesocket(pClientInfo->hClientSocket);
                ExitThread(pClientInfo->txThId);
                ExitThread(GetCurrentThreadId());
            }
            Sleep(1000);
        }else{
            if((pClientInfo->primaConn == 0) && (pClientInfo->indirizzo != 0)){
                pClientInfo->connessione = setConnect(GetCurrentThreadId(), pClientInfo->indirizzo, ip);
                if(pClientInfo->connessione == 1){
                    pClientInfo->primaConn = 1;
                }
                //THREAD TX for each client
                clientTxThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)txThread, 
                                              pClientInfo,0,&pClientInfo->txThId);
                if ( clientTxThread == NULL ){
                    printf("Unable to create client thread");
                } else {
                    CloseHandle( clientTxThread ) ;
                }
            }
            if(recv( pClientInfo -> hClientSocket, szClientMsg, sizeof( szClientMsg ), 0  ) > 0){
                strcpy(bufferRx[j].packet, szClientMsg);
                memset(&szClientMsg[0], 0, sizeof(szClientMsg));
                pClientInfo->indirizzo = calcolaHighLow(bufferRx[j].packet[1], bufferRx[j].packet[2],  
                                                       bufferRx[j].packet[3], bufferRx[j].packet[4]);
                Enqueue(Q,  bufferRx[j].packet);
                j++;
                strncpy(message, "ACK\n\r",5);
                send(pClientInfo -> hClientSocket , message , 5 , 0);
            }
        }
    }
    return(TRUE);
}

CPU works 100% with this solution.
GeneralRe: recv no blocking Pin
CPallini29-Jun-15 23:01
mveCPallini29-Jun-15 23:01 
GeneralRe: recv no blocking Pin
mosine29-Jun-15 23:06
mosine29-Jun-15 23:06 
GeneralRe: recv no blocking Pin
CPallini29-Jun-15 23:24
mveCPallini29-Jun-15 23:24 
GeneralRe: recv no blocking Pin
Daniel Pfeffer30-Jun-15 8:12
professionalDaniel Pfeffer30-Jun-15 8:12 
GeneralRe: recv no blocking Pin
Albert Holguin30-Jun-15 13:26
professionalAlbert Holguin30-Jun-15 13:26 
GeneralRe: recv no blocking Pin
Daniel Pfeffer30-Jun-15 17:53
professionalDaniel Pfeffer30-Jun-15 17:53 
GeneralRe: recv no blocking Pin
Albert Holguin1-Jul-15 4:02
professionalAlbert Holguin1-Jul-15 4:02 
GeneralRe: recv no blocking Pin
Albert Holguin30-Jun-15 13:27
professionalAlbert Holguin30-Jun-15 13:27 
QuestionCan a modeless Dialog Box be a main window "m_pMainWnd" Pin
ForNow29-Jun-15 5:07
ForNow29-Jun-15 5:07 
AnswerRe: Can a modeless Dialog Box be a main window "m_pMainWnd" Pin
Richard MacCutchan29-Jun-15 5:12
mveRichard MacCutchan29-Jun-15 5:12 
GeneralRe: Can a modeless Dialog Box be a main window "m_pMainWnd" Pin
ForNow29-Jun-15 5:22
ForNow29-Jun-15 5:22 
QuestionCan anybody help me with converting this example for x64? Pin
Member 802436529-Jun-15 2:42
Member 802436529-Jun-15 2:42 
SuggestionRe: Can anybody help me with converting this example for x64? Pin
Richard MacCutchan29-Jun-15 3:36
mveRichard MacCutchan29-Jun-15 3:36 
QuestionQ: CTreeCtrl: How to over-ride default selection of item Pin
ShivaPrasadGadapa28-Jun-15 23:43
ShivaPrasadGadapa28-Jun-15 23:43 
QuestionDraw in front of bitmap Pin
lor7527-Jun-15 8:11
lor7527-Jun-15 8:11 
AnswerRe: Draw in front of bitmap Pin
Richard MacCutchan27-Jun-15 21:11
mveRichard MacCutchan27-Jun-15 21:11 
GeneralRe: Draw in front of bitmap Pin
lor7527-Jun-15 22:22
lor7527-Jun-15 22: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.