VStarCamFinder.cc 825 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "VStarCam/Finder.h"
  2. #include <Logging.h>
  3. #include <sstream>
  4. #include <string>
  5. int main(int argc, char** argv)
  6. {
  7. try
  8. {
  9. Logging::OpenLog();
  10. Logging::SetLogMask(Logging::Severity::Info);
  11. if (argc != 2)
  12. {
  13. std::stringstream ss;
  14. ss << "Usage: " << argv[0] << " <ipaddress>";
  15. Logging::Log(Logging::Severity::Error, ss.str());
  16. return 1;
  17. }
  18. std::string ipAddress(argv[1]);
  19. int port = 0;
  20. VStarCam::Finder finder("192.168.101.100");
  21. port = finder.GetPort(ipAddress);
  22. if (port != 0)
  23. {
  24. std::stringstream ss;
  25. ss << port;
  26. Logging::Log(Logging::Severity::Error, ss.str());
  27. return 0;
  28. }
  29. return 1;
  30. }
  31. catch (const std::exception& e)
  32. {
  33. std::stringstream ss;
  34. ss << "ERROR: " << e.what() << std::endl;
  35. Logging::Log(Logging::Severity::Error, ss.str());
  36. return 1;
  37. }
  38. }