Revision: 40698
http://brlcad.svn.sourceforge.net/brlcad/?rev=40698&view=rev
Author: davidloman
Date: 2010-09-27 15:40:45 +0000 (Mon, 27 Sep 2010)
Log Message:
-----------
Added PkgServer::connectToHost(...) to support making outgoing connections!
Modified Paths:
--------------
rt^3/trunk/include/PkgServer.h
rt^3/trunk/src/libPkgCpp/PkgServer.cxx
Modified: rt^3/trunk/include/PkgServer.h
===================================================================
--- rt^3/trunk/include/PkgServer.h 2010-09-27 14:51:05 UTC (rev 40697)
+++ rt^3/trunk/include/PkgServer.h 2010-09-27 15:40:45 UTC (rev 40698)
@@ -36,6 +36,7 @@
virtual ~PkgServer();
bool listen(unsigned short port);
+ PkgClient* connectToHost(std::string ipOrHostname, short port);
/*
* This function blocks if waitTime is set to '0'. '0' is default.
Modified: rt^3/trunk/src/libPkgCpp/PkgServer.cxx
===================================================================
--- rt^3/trunk/src/libPkgCpp/PkgServer.cxx 2010-09-27 14:51:05 UTC (rev
40697)
+++ rt^3/trunk/src/libPkgCpp/PkgServer.cxx 2010-09-27 15:40:45 UTC (rev
40698)
@@ -27,6 +27,8 @@
#include "brlcad/pkg.h"
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <sstream>
PkgServer::PkgServer(std::string proto)
{
@@ -37,6 +39,25 @@
PkgServer::~PkgServer()
{}
+/**
+ * Attempts to open a new connection to ipOrHostname:port. Returns NULL if
connection fails for any reason.
+ */
+PkgClient*
+PkgServer::connectToHost(std::string ipOrHostname, short port)
+{
+ std::stringstream ss;
+ ss << port;
+ std::string s_port = ss.str();
+
+ pkg_conn* conn = pkg_open(ipOrHostname.c_str(), s_port.c_str(),
this->proto.c_str(), NULL, NULL, NULL, NULL);
+
+ if (conn == PKC_ERROR) {
+ bu_log("Connection to %s, port %d, failed.\n",
ipOrHostname.c_str(), port);
+ return NULL;
+ }
+ return this->getNewClient(conn);
+}
+
bool
PkgServer::listen(unsigned short port)
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits