Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "tfarmproxy.h"
Toshihiro Shimizu 890ddd
#include "ttcpip.h"
Toshihiro Shimizu 890ddd
#include <qstringlist></qstringlist>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QString TFarmProxy::sendToStub(const QString &data) {
Shinya Kitaoka 120a6e
  TTcpIpClient client;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int sock;
Shinya Kitaoka 120a6e
  int ret = client.connect(m_hostName, m_addr, m_port, sock);
Shinya Kitaoka 120a6e
  if (ret != OK) {
Shinya Kitaoka 120a6e
    throw CantConnectToStub(m_hostName, m_addr, m_port);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QString reply;
Shinya Kitaoka 120a6e
  ret = client.send(sock, data, reply);
Shinya Kitaoka 120a6e
  if (ret != OK) {
Shinya Kitaoka 120a6e
    client.disconnect(sock);
Shinya Kitaoka 120a6e
    throw CantConnectToStub(m_hostName, m_addr, m_port);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  client.disconnect(sock);
Shinya Kitaoka 120a6e
  return reply;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
otakuto 158f9f
int TFarmProxy::extractArgs(const QString &s, std::vector<qstring> &argv) {</qstring>
Shinya Kitaoka 120a6e
  argv.clear();
Shinya Kitaoka 120a6e
  if (s == "") return 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QStringList sl = s.split(',');
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < sl.size(); i++) argv.push_back(sl.at(i));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return argv.size();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TString CantConnectToStub::getMessage() const {
otakuto 158f9f
  std::string msg("Unable to connect to ");
Shinya Kitaoka 120a6e
  msg += m_hostName.toStdString();
Shinya Kitaoka 120a6e
  msg += " on port ";
Shinya Kitaoka 120a6e
  msg += std::to_string(m_port);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return ::to_wstring(msg);
Toshihiro Shimizu 890ddd
}