LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-25-2010, 07:40 AM   #1
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Rep: Reputation: 16
Client Server in C++


I want to write a client server aplication,but I wonder if you can help me figure out what its the best implementation(using inheritance). My code for the classes is like this,any sugestions would be apreciate:
Code:
namespace SocketSpace {
  class Error {
  public:
    Error(const std::string& msg = 0) throw();
    const char* what() throw();
    ~Error() throw();
  private:
    std::string message_m;
  };

  class TCPSocket {
  public:
    virtual void send(std::string buffer_m) throw(Error);
    virtual void recv(std::string buffer_m) throw(Error);
    void showUser() throw(Error);
    void showForeignUser() throw(Error);
    void create() throw(Error);
    void bind() throw(Error);
    void close() throw(Error);
  };

  class TCPClient: public TCPSocket {
  public:
    void connect() throw(Error);
  };

  class TCPServer: public TCPSocket {
    void accept() throw(Error);
    void listen() throw(Error);
  };
}
 
Old 11-26-2010, 01:33 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
If you're going to use sockets then, personally, I'd recommend just using C sockets. Period.

If you insist on using C++ "classes", then I'd recommend using a class library that's already built for you.

Specifically, I'd recommend taking a look at Boost:

http://www.boost.org/

'Hope that helps
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to login multiple client pc on using via openvpn server from client side raja6525 Linux - Networking 1 11-24-2010 09:42 AM
[SOLVED] zencafe - server to client pc, all working except client pc getting internt access captain_sensible Linux - Newbie 3 06-08-2010 10:37 AM
can not connect to my pureftp server from Linux client, but i can from windows client bonito SUSE / openSUSE 5 03-16-2005 09:45 PM
Refresh client user list at autentication client/server network. robertoneto123 Linux - Networking 0 11-11-2003 10:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration