Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:04:08+00:00 2026-06-05T20:04:08+00:00

Assume that there’s no problem with my header file and some included library. I’m

  • 0

Assume that there’s no problem with my header file and some included library. I’m using Winsock2.

//main.cpp and this code is okie, I omit some codes for readable reason
SOCKET ClientSocket;
ClientSocket = INVALID_SOCKET;
ClientSocket = accept(ListenSocket, NULL, NULL);
cout <<"a client is connected" << endl;
ClientConnection connection(ClientSocket);
connection.run();

//ClientConnection.h I tested any function and it's okie
class ClientConnection{
    private:
        SOCKET connectedSocket;
        bool connected;
    public:
        ClientConnection(const ClientConnection &con);
        ClientConnection(SOCKET s);
        int processMessage(string message);
        void sendMessage(string message);
        string recvMessage();
        int run();
        void printSomething(); //function just print something such as :"Here"
};

In run() function, I call the recvMessage() to get the message from client then I call processMessage(message). This is my processMessage(message) and sendMessage:

void ClientConnection::sendMessage(string mess){
    const char* sendBuff = mess.c_str();    
    int error = send(this->connectedSocket,sendBuff, (int)strlen(sendBuff), 0);
    delete sendBuff;
    return ;
}
int ClientConnection::processMessage(string message){
    cout << "This is message from client:\n" << message << endl;
    ImageProcessingPlugin *plugin = new ImageProcessingPlugin();
    plugin-> processMessage( *this, message);
    delete plugin;
    return 0;
}

This is ImageProcessingPlugin:

// ImageProcessingPlugin.h
class ImageProcessingPlugin : public Plugin{
public:
    ImageProcessingPlugin();
    void processMessage(const ClientConnection &connection, string message);
};
// ImageProcessingPlugin.cpp
void ImageProcessingPlugin::processMessage(const ClientConnection& _connection,  string message){
    ClientConnection connection(_connection);
    connection.printSomething() // It's okie
    connection.sendMessage("Server received"); // Problem goes here!!
    return;
}

After debugging, when I call printSomething() in plugin->processMessage, it’s still ok, but when I go to sendMessage, the client still got the message “Server received” from server, but there was an error: “_Block_Type_IS_VALID(pHead->nBlockUse)”! Anyone can solve my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:04:09+00:00Added an answer on June 5, 2026 at 8:04 pm

    Your deleting delete sendBuff; here, but you never allocated the memory yourself. Try removing that line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hibernate pojo class and it has some field. Assume that there
I would like to know how this can be achieved. Assume: That there's a
I assume that there is probably no satisfactory answer to this question, but I
Assume that I have some HTML page, and a corresponding CSS file. I'd like
We all know that most applications out there assume class names to follow the
This question assumes there's a blessed central repository that members of a team clone
Assume that I have this piece of code: @interface Foo : NSObject { Bar
Assume that there is a PHP variable: $variable = 'username'; cookie value = 'username'
This Microsoft support page shows that there is no Win32 equivalent to C Run-Time's
Learning java server technologies, trying to clarify some things. There are few technologies that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.