2001-10-08 19:24:46 +00:00
|
|
|
#include "CClient.h"
|
2001-11-19 00:33:36 +00:00
|
|
|
#include "CString.h"
|
|
|
|
#include "CNetwork.h"
|
2001-10-08 19:24:46 +00:00
|
|
|
#include "CNetworkAddress.h"
|
2001-10-14 18:29:43 +00:00
|
|
|
#include "CThread.h"
|
2001-10-08 19:24:46 +00:00
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
void realMain(const CString& name,
|
|
|
|
const CString& hostname,
|
2002-05-22 16:51:59 +00:00
|
|
|
UInt16 port)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2001-10-14 18:29:43 +00:00
|
|
|
CThread::init();
|
2001-11-19 00:33:36 +00:00
|
|
|
CNetwork::init();
|
|
|
|
|
|
|
|
CClient* client = NULL;
|
|
|
|
try {
|
|
|
|
CNetworkAddress addr(hostname, port);
|
|
|
|
client = new CClient(name);
|
|
|
|
client->run(addr);
|
|
|
|
delete client;
|
|
|
|
CNetwork::cleanup();
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
delete client;
|
|
|
|
CNetwork::cleanup();
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_PLATFORM_WIN32)
|
|
|
|
|
|
|
|
#include "CMSWindowsScreen.h"
|
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
|
|
|
{
|
|
|
|
CMSWindowsScreen::init(instance);
|
|
|
|
|
|
|
|
if (__argc != 2) {
|
|
|
|
CString msg = "hostname required. exiting.";
|
|
|
|
MessageBox(NULL, msg.c_str(), "error", MB_OK | MB_ICONERROR);
|
|
|
|
return 1;
|
|
|
|
}
|
2001-10-14 18:29:43 +00:00
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
try {
|
2001-11-25 18:32:41 +00:00
|
|
|
realMain("secondary", __argv[1], 50001);
|
2001-11-19 00:33:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
catch (XBase& e) {
|
|
|
|
CString msg = "failed: ";
|
|
|
|
msg += e.what();
|
|
|
|
MessageBox(NULL, msg.c_str(), "error", MB_OK | MB_ICONERROR);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2001-10-08 19:24:46 +00:00
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(stderr, "usage: %s <hostname>\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2001-11-25 18:32:41 +00:00
|
|
|
realMain("secondary", argv[1], 50001);
|
2001-11-19 00:33:36 +00:00
|
|
|
return 0;
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
catch (XBase& e) {
|
|
|
|
fprintf(stderr, "failed: %s\n", e.what());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2001-11-19 00:33:36 +00:00
|
|
|
|
|
|
|
#endif
|