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

  • Home
  • SEARCH
  • 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 3961350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:57:53+00:00 2026-05-20T02:57:53+00:00

#ifndef _ClientSocket_H_ #define _ClientSocket_H_ #include Includes.h #include LOGMSGs.h class cSocket { public: cSocket(); bool

  • 0
#ifndef _ClientSocket_H_
#define _ClientSocket_H_

#include "Includes.h"
#include "LOGMSGs.h"

class cSocket
{
public:
    cSocket();
    bool Open();
    bool Listen(char *OnIP,int OnPort);
    void Send(char *MSG, int len);
    void Recv(char *MSG,int len);
    void Close();
protected:
    SOCKET  cSock;
    const int   SndBuf;
};

#endif


#include "ClientSocket.h"


bool cSocket::Open()
{
    WSADATA wsaData;
    int err;
    if((err =WSAStartup(0x202, &wsaData)) !=0)
    {
        Error("Init WSAStartup() failed[%d].", err);
        return false;
    }
    return true;
}

bool cSocket::Listen(char *OnIP,int OnPort)
{
    if(Open())
    {
        //Create the main socket
        cSock=socket(AF_INET, SOCK_STREAM, 0);
        if(cSock==INVALID_SOCKET)
        {
            int err = WSAGetLastError();
            //WSACleanup();
            printf("Init socket() failed[%d].", err);
            return FALSE;
        }

        //Set the REUSEADDR SOCKET
        int     optval = 1;
        if(setsockopt(cSock, SOL_SOCKET, SO_REUSEADDR, (char *) &optval, sizeof(optval)))
        {
            int err = WSAGetLastError();
            Close();
            printf("Init setsockopt() SO_REUSEADDR failed[%d].", err);
            return FALSE;
        }

        //Set the KEEPALIVE SOCKET
        optval = 1;
        if(setsockopt(cSock, SOL_SOCKET, SO_KEEPALIVE, (char *) &optval, sizeof(optval)))
        {
            int err = WSAGetLastError();
            Close();
            printf("Init setsockopt() SO_KEEPALIVE failed[%d].", err);
            return FALSE;
        }

            // Set the SNDBUF SOCKET
        if(SndBuf)      // Non-0: pointer SNDBUG
        {
            optval = SndBuf;
            if(setsockopt(cSock, SOL_SOCKET, SO_SNDBUF, (char *) &optval, sizeof(optval)))
            {
                int err = WSAGetLastError();
                Close();
                printf("Init setsockopt() SO_SNDBUF failed[%d].", err);
                return FALSE;
            }

            // Read the SNDBUF SOCKET
            int ret = sizeof(optval);
            if(getsockopt(cSock, SOL_SOCKET, SO_SNDBUF, (char *) &optval, &ret) == 0)
            {
                LOGMSG("send buffer size SOCKET [%d] K.", optval/1024);
            }
        }

        SOCKADDR_IN     sin;
        memset(&sin, 0, sizeof(sin));
        sin.sin_family      = AF_INET;
        sin.sin_addr.s_addr = inet_addr(OnIP);
        sin.sin_port        = htons(OnPort);
        if(bind(cSock, (LPSOCKADDR) &sin, sizeof(sin)))
        {
            int err = WSAGetLastError();
            Close();
            printf("Init bind() failed[%d].", err);
            return FALSE;
        }

        //Set to non-blocking mode
        unsigned long   i = 1;
        if(ioctlsocket(cSock, FIONBIO, &i))
        {
            int err = WSAGetLastError();
            Close();
            printf("Init ioctlsocket() failed[%d].", err);
            return FALSE;
        }

        //Listening port
        if(listen(cSock, SOMAXCONN))        // SOMAXCONN: WIN macro definition
        {
            int err = WSAGetLastError();
            Close();
            printf("Init listen() failed[%d].", err);
            return FALSE;
        }
        return true;
    }
return false;
}


void cSocket::Close()
{
    closesocket(cSock);
    WSACleanup();
}


#include "Includes.h"
#include "LOGMSGs.h"
#include "auth_proto.h"
#include "Packets.h"
#include "ClientSocket.h"


int main(int argc, char* argv[]) 
{
    cSocket sock;
    while(1)
    {
        sock.Open();
        sock.Listen("127.0.0.1",4444);
    }
    return 0;
}

Error: unresolved external symbol “public: __thiscall cSocket::cSocket(void)” (??0cSocket@@QAE@XZ) referenced in function _main

what’s wrong?

  • 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-05-20T02:57:53+00:00Added an answer on May 20, 2026 at 2:57 am

    This is a linker error, which means that the compiler has checked that the code contains no syntax errors, but the linker can’t find an implementation of a function you’ve tried to call somewhere in the program. In this case, the function it can’t find is

    __thiscall cSocket::cSocket(void)" (??0cSocket@@QAE@XZ) 
    

    This function looks cryptic because of name-mangling, where the compiler takes the in-source name of a function and then transforms it in a way that allows for better type-safe linking. However, you can still see that at the code of this is the function name

    cSocket::cSocket(void)
    

    This is constructor for cSocket. If you’ll notice, nowhere in the code have you defined this constructor, which is why the linker can’t find an implementation for it. Modifying your code by adding an implementation should help fix this.

    More generally, though, if you ever see an error like this, it usually means that you’ve promised the compiler that some function or object exists through a function prototype or extern declaration, but didn’t give an object file to the linker containing its definition. The main causes of this usually are (in roughly this order);

    1. You prototyped a function but forgot to implement it. That’s what happened here, I think.
    2. You prototyped a function, but then implemented it with a different signature. For example, if you prototype a function void MyFunction(int) but then implement the function either as void MyFunction(int&) or as void MyFunction(), the linker will consider this an overload rather than an implementation and will give you the error at link-time rather than compile-time.
    3. You compiled code with the definition, but didn’t link it in. This could happen if you have a multi-file project and then forget to pass one of the files as input to the linker.

    Hope this helps!

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

Sidebar

Related Questions

No related questions found

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.