Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CreateFile function Pin
Richard Andrew x6411-Oct-11 11:33
professionalRichard Andrew x6411-Oct-11 11:33 
GeneralRe: CreateFile function Pin
Peter_in_278011-Oct-11 12:06
professionalPeter_in_278011-Oct-11 12:06 
GeneralRe: CreateFile function Pin
Albert Holguin12-Oct-11 5:17
professionalAlbert Holguin12-Oct-11 5:17 
GeneralRe: CreateFile function Pin
Albert Holguin12-Oct-11 5:19
professionalAlbert Holguin12-Oct-11 5:19 
GeneralRe: CreateFile function Pin
Software_Developer12-Oct-11 9:28
Software_Developer12-Oct-11 9:28 
AnswerRe: How to get list of COM Ports in Win32 Pin
Randor 11-Oct-11 17:47
professional Randor 11-Oct-11 17:47 
GeneralRe: How to get list of COM Ports in Win32 Pin
pandit8411-Oct-11 20:18
pandit8411-Oct-11 20:18 
QuestionSaving File as JPEG - Encoding problems Pin
Naniw10-Oct-11 23:02
Naniw10-Oct-11 23:02 
Hello! I have a function that saves a jpeg file from an IP camera. It works sometimes, but sometimes, it doesnt. When I investigated, i found out that in the instances that it didnt work, the characters of the file when i convert it to a text file looks like this:

ෝ㚆��鍫᱉㓉��⛷통⌫㘿答窂脚麜鋴ᬓ犚厜褝沣놊��ꋂ᝚䴍㢛諱᷐锫잛䕡逺Řޥ舔룣⣅‵쭫帏갪ಱ彗䩂䖒깔숢⢞ᴑ鎵졋쮧呤ᑵ蛝㙕횇涚噈혘㙌๝සᲷ貚臛诞

Proper jpeg files have characters that look like this:

*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³

I don't know what's wrong. Please help me!!! Here is the function I'm using:

XML
int SendReceiveTest1( Socket^ server )
{
    FileStream^ ambot = File::Create("pastilan.jpg");
    array<Byte>^ msg = Encoding::UTF8->GetBytes("GET /snapshot.cgi HTTP/1.1\r\n");
    array<Byte>^ msg1 = Encoding::UTF8->GetBytes("Authorization: Basic YWRtaW46\r\n\r\n");
    array<Byte>^ header = gcnew array<Byte>(224);
    array<Byte>^ bytes = gcnew array<Byte>(30000);
    try
    {
      // Blocks until send returns.
    Int32 byteCount = server->Send( msg );
    Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() );

    Int32 byteCount1 = server->Send( msg1 );
    Console::WriteLine( "Sent {0} bytes.", byteCount1.ToString() );

    byteCount = server->Receive( header, header->Length, SocketFlags::None );
    if ( byteCount > 0 )
    {
        Console::WriteLine( Encoding::UTF8->GetString( header ) );
    }

    while(byteCount > 0){
        byteCount = server->Receive( bytes, server->Available, SocketFlags::None);
    }

    ambot->Write( bytes, 0, bytes->Length );

    if( ambot )
        delete (IDisposable^)ambot;
    }
    catch ( SocketException^ e )
    {
        Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() );
        return ( e->ErrorCode );
    }
    return 0;
}


Usually I dont bother asking if it NEVER works. But Im worried about this particular code because most of the time it DOES work. Thanks!!!
AnswerRe: Saving File as JPEG - Encoding problems Pin
Richard MacCutchan11-Oct-11 0:10
mveRichard MacCutchan11-Oct-11 0:10 
GeneralRe: Saving File as JPEG - Encoding problems Pin
Naniw11-Oct-11 1:08
Naniw11-Oct-11 1:08 
GeneralRe: Saving File as JPEG - Encoding problems Pin
Richard MacCutchan11-Oct-11 5:21
mveRichard MacCutchan11-Oct-11 5:21 
AnswerRe: Saving File as JPEG - Encoding problems Pin
Luc Pattyn11-Oct-11 6:03
sitebuilderLuc Pattyn11-Oct-11 6:03 
GeneralMessage Removed Pin
11-Oct-11 16:29
Naniw11-Oct-11 16:29 
GeneralRe: Saving File as JPEG - Encoding problems Pin
Luc Pattyn11-Oct-11 16:33
sitebuilderLuc Pattyn11-Oct-11 16:33 
GeneralRe: Saving File as JPEG - Encoding problems Pin
Naniw11-Oct-11 16:38
Naniw11-Oct-11 16:38 
GeneralRe: Saving File as JPEG - Encoding problems Pin
Luc Pattyn11-Oct-11 22:33
sitebuilderLuc Pattyn11-Oct-11 22:33 
GeneralRe: Saving File as JPEG - Encoding problems Pin
Naniw11-Oct-11 1:10
Naniw11-Oct-11 1:10 
AnswerRe: Saving File as JPEG - Encoding problems Pin
Chris Losinger11-Oct-11 3:35
professionalChris Losinger11-Oct-11 3:35 
QuestionRe: Saving File as JPEG - Encoding problems Pin
David Crow11-Oct-11 4:07
David Crow11-Oct-11 4:07 
QuestionSetting a bmp as a window background Pin
jkirkerx10-Oct-11 13:40
professionaljkirkerx10-Oct-11 13:40 
AnswerRe: Setting a bmp as a window background Pin
TheGreatAndPowerfulOz10-Oct-11 14:45
TheGreatAndPowerfulOz10-Oct-11 14:45 
GeneralRe: Setting a bmp as a window background Pin
jkirkerx10-Oct-11 16:01
professionaljkirkerx10-Oct-11 16:01 
GeneralRe: Setting a bmp as a window background Pin
jkirkerx10-Oct-11 16:14
professionaljkirkerx10-Oct-11 16:14 
GeneralRe: Setting a bmp as a window background Pin
Richard MacCutchan10-Oct-11 22:15
mveRichard MacCutchan10-Oct-11 22:15 
GeneralRe: Setting a bmp as a window background Pin
jkirkerx11-Oct-11 7:01
professionaljkirkerx11-Oct-11 7:01 

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.