Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

CORE CLIENT-SIDE CLASSES

An easy example of an extension of the BaseSocketManager class is a class to manage the client side of a game. Its job is to create a single socket that attaches to a known server.

class ClientSocketManager : public BaseSocketManager
{
  std::string m_HostName;
  unsigned int m_Port;

public:
  ClientSocketManager(const std::string &hostName, unsigned int port)
  {
    m_HostName = hostName;
    m_Port = port;
  }
  bool Connect();
};

bool ClientSocketManager::Connect()
{
  if (!BaseSocketManager::Init())
    return false;

  RemoteEventSocket *pSocket = GCC_NEW RemoteEventSocket;

  if (!pSocket->Connect(GetHostByName(m_HostName), m_Port) )
  {
    SAFE_DELETE(pSocket);
    return false;
  }
  AddSocket(pSocket);
  return true;
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial