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 6884043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:27:32+00:00 2026-05-27T05:27:32+00:00

i just built a template implementation of my boost network. here is my template

  • 0

i just built a template implementation of my boost network.

here is my template class who is calling my network class :

AbstractNetwork.hpp :

#include "Network.hpp"

template <typename T, typename R, typename S, typename A>
class       AbstractNetwork
{
private:
    T       connection;

public:
AbstractNetwork(A acceptor)
{
    connection = T::create(acceptor);
}

void write(const R msg)
{
    connection->Swrite(msg);
}

R read(void)
{
    connection->Sread();
    return (connection->getIdata());
}

S getSocket(void)
{
    return (connection->getSocket());
}

void close(void)
{
    connection->close();
}
};

and this is my network class who is working with a boost::tcp::socket :

Network.hpp

class       Network : public boost::enable_shared_from_this<Network>
{
private:
    tcp::socket                     socket;
    std::vector<char>               Idata;
    char                            Iheader[MYINT];
    bool                            readHeader;
    void                            endRead(const error_code& error, size_t nbytes);
    void                            endWrite(const error_code &error);
    size_t                          Isize;

public:
    typedef boost::shared_ptr<Network> ptr;

    Network(io_service &);
    ~Network();
    void                close(void);
    void                Sread(void);
    void                Swrite(Commande *);
    tcp::socket&        getSocket(void);
    Commande*           getIdata(void);
    std::string         convertHeader(void);
    static ptr          create(io_service &);
};

i don’t give all of function’s code because it’s too long and i’m sure it works.

When i build this project i have this following error under VS2010 ultimate :

error LNK2001: unresolved external symbol "public: void __thiscall AbstractNetwork<class boost::shared_ptr<class Network>,struct Commande *,class boost::asio::basic_stream_socket<class boost::asio::ip::tcp,class boost::asio::stream_socket_service<class boost::asio::ip::tcp> > &,class boost::asio::io_service &>::close(void)"

error LNK2001: unresolved external symbol "public: void __thiscall AbstractNetwork<class boost::shared_ptr<class Network>,struct Commande *,class boost::asio::basic_stream_socket<class boost::asio::ip::tcp,class boost::asio::stream_socket_service<class boost::asio::ip::tcp> > &,class boost::asio::io_service &>::write(struct Commande * const)"

error LNK2001: unresolved external symbol "public: class boost::asio::basic_stream_socket<class boost::asio::ip::tcp,class boost::asio::stream_socket_service<class boost::asio::ip::tcp> > & __thiscall AbstractNetwork<class boost::shared_ptr<class Network>,struct Commande *,class boost::asio::basic_stream_socket<class boost::asio::ip::tcp,class boost::asio::stream_socket_service<classboost::asio::ip::tcp> > &,class boost::asio::io_service &>::getSocket(void)"

error LNK2001: unresolved external symbol "public: __thiscall AbstractNetwork<class boost::shared_ptr<class Network>,struct Commande *,class boost::asio::basic_stream_socket<class boost::asio::ip::tcp,class boost::asio::stream_socket_service<class boost::asio::ip::tcp> > &,class boost::asio::io_service &>::AbstractNetwork<class boost::shared_ptr<class Network>,struct Commande *,classboost::asio::basic_stream_socket<class boost::asio::ip::tcp,class boost::asio::stream_socket_service<class boost::asio::ip::tcp> > &,class boost::asio::io_service &>(class boost::asio::io_service &)

it’s long, but i want to give you all of these error because i think the problem come to my template type. so i think my problem come to AbstractNetwork.hpp but i can’t find this.

Did you have any idea about that ?

  • 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-27T05:27:32+00:00Added an answer on May 27, 2026 at 5:27 am

    Fix your class. You don’t need to repeat the template for each class member function, they’re part of the template class already.

    template <typename T, typename R, typename S, typename A>
    class       AbstractNetwork
    {
    private:
        T       connection;
    
    public:
    AbstractNetwork(A acceptor)
    {
        this->connection = T::create(acceptor);
    }
    
    void write(const R msg)
    {
        this->connection->Swrite(msg);
    }
    
    read(void)
    {
        this->connection->Sread();
        return (this->connection->getIdata());
    }
    
    getSocket(void)
    {
        return (this->connection->getSocket());
    }
    
    close(void)
    {
        this->close(); //  <<--- is this a mistake?
        //Probably you wanted this->connection->close();
    }
    
    };
    

    Apart from the apparent typo in close, you also don’t need to use this everywhere, its redundant and makes the code look messier.

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

Sidebar

Related Questions

I just built a setup.msi file using the Web Setup Project template within Visual
i just upgraded to wordpress 3.3 and built a really basic template for some
I built the Command Line tool (Foundation) template in Xcode. It just logs Hello
I just built an application in ASP.net that returns a PNG image. The resulting
I just built a WPF form that contains a ListBox. The ListBox has bound
I've just built a VS C++ 6.0 program using VS 2008. When I attempt
I've just built a basic ASP MVC web site for deployment on our intranet.
I have just built up my first SVN server, along with the mod_dav_svn module
I've just built a crap load of Telerik reports for my web site project,
I know this sounds confusing: I have just built some basic prev/next pagination for

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.