Click here to Skip to main content
14,424,458 members

C / C++ / MFC

 
GeneralRe: Problem displaying CStatic text item Pin
jeron11-Jul-15 12:32
Memberjeron11-Jul-15 12:32 
GeneralRe: Problem displaying CStatic text item Pin
ForNow1-Jul-15 13:19
MemberForNow1-Jul-15 13:19 
GeneralRe: Problem displaying CStatic text item Pin
ForNow2-Jul-15 14:27
MemberForNow2-Jul-15 14:27 
Questionrecv no blocking Pin
mosine29-Jun-15 22:33
Membermosine29-Jun-15 22:33 
AnswerRe: recv no blocking Pin
CPallini29-Jun-15 22:54
mveCPallini29-Jun-15 22:54 
GeneralRe: recv no blocking Pin
mosine29-Jun-15 23:21
Membermosine29-Jun-15 23:21 
GeneralRe: recv no blocking Pin
CPallini29-Jun-15 23:35
mveCPallini29-Jun-15 23:35 
GeneralRe: recv no blocking Pin
mosine29-Jun-15 23:52
Membermosine29-Jun-15 23:52 
I post my code:
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
CPallini30-Jun-15 0:01
mveCPallini30-Jun-15 0:01 
GeneralRe: recv no blocking Pin
mosine30-Jun-15 0:06
Membermosine30-Jun-15 0:06 
GeneralRe: recv no blocking Pin
CPallini30-Jun-15 0:24
mveCPallini30-Jun-15 0:24 
GeneralRe: recv no blocking Pin
Daniel Pfeffer30-Jun-15 9:12
professionalDaniel Pfeffer30-Jun-15 9:12 
GeneralRe: recv no blocking Pin
Albert Holguin30-Jun-15 14:26
professionalAlbert Holguin30-Jun-15 14:26 
GeneralRe: recv no blocking Pin
Daniel Pfeffer30-Jun-15 18:53
professionalDaniel Pfeffer30-Jun-15 18:53 
GeneralRe: recv no blocking Pin
Albert Holguin1-Jul-15 5:02
professionalAlbert Holguin1-Jul-15 5:02 
GeneralRe: recv no blocking Pin
Albert Holguin30-Jun-15 14:27
professionalAlbert Holguin30-Jun-15 14:27 
QuestionCan a modeless Dialog Box be a main window "m_pMainWnd" Pin
ForNow29-Jun-15 6:07
MemberForNow29-Jun-15 6:07 
AnswerRe: Can a modeless Dialog Box be a main window "m_pMainWnd" Pin
Richard MacCutchan29-Jun-15 6:12
communityengineerRichard MacCutchan29-Jun-15 6:12 
GeneralRe: Can a modeless Dialog Box be a main window "m_pMainWnd" Pin
ForNow29-Jun-15 6:22
MemberForNow29-Jun-15 6:22 
QuestionCan anybody help me with converting this example for x64? Pin
Member 802436529-Jun-15 3:42
MemberMember 802436529-Jun-15 3:42 
SuggestionRe: Can anybody help me with converting this example for x64? Pin
Richard MacCutchan29-Jun-15 4:36
communityengineerRichard MacCutchan29-Jun-15 4:36 
QuestionQ: CTreeCtrl: How to over-ride default selection of item Pin
ShivaPrasadGadapa29-Jun-15 0:43
MemberShivaPrasadGadapa29-Jun-15 0:43 
QuestionDraw in front of bitmap Pin
lor7527-Jun-15 9:11
Memberlor7527-Jun-15 9:11 
AnswerRe: Draw in front of bitmap Pin
Richard MacCutchan27-Jun-15 22:11
communityengineerRichard MacCutchan27-Jun-15 22:11 
GeneralRe: Draw in front of bitmap Pin
lor7527-Jun-15 23:22
Memberlor7527-Jun-15 23: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.