Hello All,
I'm working on a project in which I'm making a TCP server that receives the images from a client and shows them on window without saving.
Code:
case WM_SOCKET:
        {
            switch(WSAGETSELECTEVENT(lParam))
            {
                case FD_READ:
                {
                    
                    char recvbuffer[102400];
                    int filebuflen = DEFAULT_BUFLEN;
                    ZeroMemory(recvbuffer, filebuflen);
                    int bytes_read = recv(Socket, recvbuffer, filebuflen, 0 );
                
                    if(bytes_read==0)
                
                break;
                    if(bytes_read <0)
                    {
                    MessageBox(hWnd,
                        "File Read Error",
                        "Corrupt File",
                        MB_ICONINFORMATION|MB_OK);
                    }

                    
                    std::ifstream is;
                    char* pbuffer;
                



                    
                    /* pbuffer = new char[bytes_read];*/
                    bytes_read = is.tellg();
                /*    is.seekg(0, std::ios::beg);*/
                    pbuffer = new char[bytes_read];
                    is.read(pbuffer, bytes_read);
                
                    is.close();
                    tagBITMAPFILEHEADER bfh = *(tagBITMAPFILEHEADER*)pbuffer;
                    tagBITMAPINFOHEADER bih = *(tagBITMAPINFOHEADER*)(pbuffer+sizeof(tagBITMAPFILEHEADER));

                    RGBQUAD             rgb = *(RGBQUAD*)(pbuffer+sizeof(tagBITMAPFILEHEADER)+sizeof(tagBITMAPINFOHEADER));


                    BITMAPINFO bi;
bi.bmiColors[0] = rgb;
bi.bmiHeader = bih;
char* pPixels = (pbuffer+bfh.bfOffBits);

char* ppvBits;


hbitmap = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**) &ppvBits, NULL, 0);
SetDIBits(NULL, hbitmap, 0, bih.biHeight, pPixels, &bi, DIB_RGB_COLORS);

GetObject(hbitmap, sizeof(BITMAP), &cBitmap);
delete[] pbuffer;
                    

                }
                break;
The problem is when I'm sending the image from client it is sent but at that time server freezes and hangs and no data received at server side.

I need urgent help.
Thanks!