Thread: Errors i'm having trouble fixing

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    15

    Errors i'm having trouble fixing

    I keep getting errors like the one I included.
    These error usually accure when the client is disconnected from the server and the function StartRecieve ends (due to connection lost).
    Can someone help me fix it ? :\
    I also included the source code.

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    15

    I guess no one knows =\

    I think the problem might be in using CString::Format or CString::GetBuffer too many times.
    Might that be?

  3. #3
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    ...

    I can actually see a problem in your code:
    checkout in your ReadLine function, you're using LastChar without having any data there, it's actually undefined.

    try something like:
    LastChar = ' ';
    and then the rest of your code.

  4. #4
    Registered User
    Join Date
    Dec 2002
    Posts
    15

    That is a mistake

    I corrected it but that doesn't fix it.
    The error happends when StartRecieve and StartCom ends (2 times)

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    1. It's impossible to tell from only a snippet of utility functions how exactly you're using (or abusing) the code.

    2. This is at best unwise
    strcat(strText, "\r\n");
    ar.Write(strText, strlen(strText));
    Who said that your string was a) modifiable, and b) with enough reserve space to add characters to the end and c) does the caller know you do this?

    Try
    ar.Write(strText, strlen(strText));
    ar.Write("\r\n", 2);
    And make your string parameter const.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Dec 2002
    Posts
    15

    =)

    Thanks alot man, that solved the problem.
    And the code I posted here is the code I wrote, I used SDI from the MFC Application menu, so i figured there's no point in posting that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fixing two errors in my code
    By ad_hoc() in forum C Programming
    Replies: 2
    Last Post: 07-13-2017, 06:46 PM
  2. Replies: 2
    Last Post: 03-26-2015, 02:45 AM
  3. Assistance in fixing errors
    By llind212 in forum C++ Programming
    Replies: 1
    Last Post: 04-13-2011, 01:16 PM
  4. Fixing Errors
    By brietje698 in forum Networking/Device Communication
    Replies: 9
    Last Post: 12-10-2007, 11:17 PM
  5. Fixing errors!
    By Zophixan in forum C++ Programming
    Replies: 2
    Last Post: 10-31-2002, 06:18 PM