git-svn-id: svn://db.shs.com.ru/pip@818 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
71
main.cpp
71
main.cpp
@@ -1,74 +1,5 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
#include <winsock2.h>
|
|
||||||
|
|
||||||
class CL: public PIObject {
|
|
||||||
PIOBJECT(CL)
|
|
||||||
public:
|
|
||||||
EVENT_HANDLER1(void, nc, PIEthernet * , client) {
|
|
||||||
piCout << "client" << client;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PIKbdListener kbd(0, 0, false);
|
|
||||||
#include <typeinfo>
|
|
||||||
#define PIIS_TYPENAME(t) typeid(t).name()
|
|
||||||
|
|
||||||
template<typename T> class Name
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const char * name() {return PIIS_TYPENAME(T);}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
//piCout << Name<PIDiagnostics::State>::name();
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
PICLI cli(argc, argv);
|
|
||||||
cli.setDebug(false);
|
|
||||||
cli.addArgument("send");
|
|
||||||
//PISystemInfo::machineID();
|
|
||||||
kbd.enableExitCapture();
|
|
||||||
kbd.start();
|
|
||||||
|
|
||||||
if (cli.hasArgument("send")) {
|
|
||||||
/*piCout << "send mode";
|
|
||||||
PIEthernet eth;
|
|
||||||
eth.setSendAddress(cli.rawArguments().back() + ":15123");
|
|
||||||
eth.open();
|
|
||||||
while (!kbd.exiting) {
|
|
||||||
eth.send(PIByteArray("test string", 12));
|
|
||||||
piMSleep(500);
|
|
||||||
}*/
|
|
||||||
PIEthernet eth(PIEthernet::TCP_Server);
|
|
||||||
eth.listen(cli.rawArguments().back() + ":15123", true);
|
|
||||||
//eth.open();
|
|
||||||
CL cl;
|
|
||||||
CONNECTU(ð, newConnection, &cl, nc);
|
|
||||||
|
|
||||||
WAIT_FOR_EXIT;
|
|
||||||
piCout << "exiting ...";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
piCout << "recv mode";
|
|
||||||
PIEthernet eth(PIEthernet::TCP_Client);
|
|
||||||
//eth.setReadAddress(cli.rawArguments().back() + ":15123");
|
|
||||||
eth.startThreadedRead();
|
|
||||||
int s = eth.socket();
|
|
||||||
piCout << s;
|
|
||||||
piCout << "connect ...";
|
|
||||||
eth.connect(cli.rawArguments().back() + /*":13361"*/":15123");
|
|
||||||
piCout << "connect done" << eth.isConnected();
|
|
||||||
//fcntl(fd, F_SETFL, O_NONBLOCK);
|
|
||||||
|
|
||||||
WAIT_FOR_EXIT;
|
|
||||||
piCout << "exiting ...";
|
|
||||||
|
|
||||||
}
|
|
||||||
/*PIThread t;
|
|
||||||
t.start(10);
|
|
||||||
//WAIT_FOR_EXIT;
|
|
||||||
piSleep(20.);
|
|
||||||
t.stop(true);*/
|
|
||||||
piCout << "exit main ...";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user