本文整理汇总了C++中Transport::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ Transport::stop方法的具体用法?C++ Transport::stop怎么用?C++ Transport::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transport
的用法示例。
在下文中一共展示了Transport::stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testClose
void TCPCONNECTIONTF::testClose()
{
TCPServerAdapter adapter;
Transport *tranServer = new Transport;
char spec[] = "tcp:localhost:13345";
tranServer->start();
IOComponent *listener = tranServer->listen(spec, _streamer, &adapter);
CPPUNIT_ASSERT(listener);
//start client
Transport *tranClient = new Transport;
tranClient->start();
Connection *conn = tranClient->connect(spec, _streamer, false);
CPPUNIT_ASSERT(conn);
CPPUNIT_ASSERT(_conn->postPacket(new ConnPacket(31), _handler, NULL));
// the close() has not implement
ANET_LOG(SPAM,"Before Calling _conn->close();");
_conn->close();
ANET_LOG(SPAM,"After Calling _conn->close();");
CPPUNIT_ASSERT(_conn->isClosed());
ANET_LOG(SPAM,"After Assert(_conn->isClosed();");
tranClient->stop();
ANET_LOG(SPAM,"After Calling tranClient->stop();");
tranClient->wait();
ANET_LOG(SPAM,"After Calling tranClient->wait();");
tranServer->stop();
ANET_LOG(SPAM,"After Calling tran_server->stop();");
tranServer->wait();
ANET_LOG(SPAM,"After Calling tranClient->wait();");
delete tranClient;
delete tranServer;
listener->subRef();
conn->subRef();
}
示例2: main
int main()
{
signal(SIGPIPE, sigHandler);
signal(SIGHUP, sigHandler);
Transport gClientTrans;
gClientTrans.start();
EchoServer server;
server.start();
for (int i = 0; i < 1; i++)
{
EchoClient* client = new EchoClient;
client->mClientTrans = &gClientTrans;
cout << "Round " << i << endl;
client->Run();
usleep(100000);
waitpid(-1, NULL, WNOHANG);
}
gClientTrans.stop();
gClientTrans.wait();
server.stop();
}
示例3: stop
void EchoServer::stop()
{
_transport.stop();
}
示例4: doProcess
void doProcess(unsigned int port, unsigned int num, CMClient& client)
{
Transport transport;
transport.start(); //using multithreads mode of anet
Thread *threads = new Thread[num];
RequestProcessor *runnables = new RequestProcessor [num];
assert(threads);
assert(runnables);
for (long i=0; i<num; i++) {
threads[i].start(runnables + i, (void*)&client);
}
HTTPPacketFactory factory;
HTTPStreamer streamer(&factory);
HTTPServerAdapter serverAdapter;
stringstream ss;
char hostname[1024];
if (gethostname(hostname, 1024) != 0) {
transport.stop();
transport.wait();
delete [] threads;
delete [] runnables;
exit(-1);
}
// ss << "tcp:" << hostname << ":" << port;
ss << "tcp:" << ":" << port;
string str = ss.str();
const char *spec = str.c_str();
IOComponent *ioc = transport.listen(spec, &streamer, &serverAdapter);
if (ioc == NULL) {
printf("create listen port error\n");
transport.stop();
transport.wait();
delete [] threads;
delete [] runnables;
return;
}
printf("webserver start ok\n");
while (!globalStopFlag) {
usleep(100000);
}
transport.stop();
transport.wait();
globalQueue._condition.lock();
while (globalQueue._queue.size()) {
HTTPRequestEntry entry = globalQueue._queue.front();
entry._packet->free();
entry._connection->subRef();
globalQueue._queue.pop();
}
globalQueue._condition.broadcast();
globalQueue._condition.unlock();
for (long i=0; i<num; i++) {
threads[i].join();
}
delete [] threads;
delete [] runnables;
}
示例5: perform
bool HostFilterComponent::perform (const InvocationInfo& info)
{
Config* config = Config::getInstance();
GraphComponent* graph = main->getGraph ();
Transport* transport = getFilter()->getTransport();
switch (info.commandID)
{
//----------------------------------------------------------------------------------------------
case CommandIDs::pluginOpen:
{
graph->loadAndAppendPlugin ();
break;
}
case CommandIDs::pluginClose:
{
graph->closeSelectedPlugins ();
break;
}
case CommandIDs::pluginClear:
{
graph->closeAllPlugins ();
break;
}
case CommandIDs::showPluginListEditor:
{
if (PluginListWindow::currentPluginListWindow == 0)
PluginListWindow::currentPluginListWindow = new PluginListWindow (knownPluginList);
PluginListWindow::currentPluginListWindow->toFront (true);
break;
}
//----------------------------------------------------------------------------------------------
#ifndef JOST_VST_PLUGIN
case CommandIDs::audioOptions:
{
StandaloneFilterWindow* window = findParentComponentOfClass ((StandaloneFilterWindow*) 0);
if (window)
window->showAudioSettingsDialog ();
break;
}
#endif
case CommandIDs::audioPlay:
{
transport->play ();
break;
}
case CommandIDs::audioPlayPause:
{
transport->togglePlay ();
break;
}
case CommandIDs::audioStop:
{
transport->stop ();
break;
}
case CommandIDs::audioRecord:
{
transport->record ();
break;
}
case CommandIDs::audioRewind:
{
transport->rewind ();
break;
}
case CommandIDs::audioLoop:
{
transport->setLooping (! transport->isLooping());
break;
}
//----------------------------------------------------------------------------------------------
case CommandIDs::sessionNew:
{
bool retValue =
AlertWindow::showYesNoCancelBox (AlertWindow::WarningIcon,
T("Unsaved Changes"),
T("Are you sure you want to close the current session? You may lose any unsaved changes."));
if (retValue)
{
closePluginEditorWindows ();
getFilter()->getHost ()->closeAllPlugins (true);
clearComponents ();
Config::getInstance()->lastSessionFile = File::nonexistent;
rebuildComponents ();
}
break;
}
case CommandIDs::sessionLoad:
{
FileChooser myChooser (T("Load a session file..."),
//.........这里部分代码省略.........
示例6: main
int main(int argc, char *argv[]) {
if(2 > argc) {
printf("Less address!\n");
return 1;
}
Logger::logSetup();
Logger::setLogLevel(0);
char *address = argv[1];
char host[100] = {0};
char path[1024*1024] = {0};
char spec[200] = {0};
int port = -1;
sscanf(address, "http://%[-a-zA-Z0-9.]:%d%s", host, &port, path);
if(0 == host[0] || -1 == port) {
sscanf(address, "%[-a-zA-Z0-9.]:%d%s", host, &port, path);
}
if(0 == host[0] || -1 == port) {
port = 80;
sscanf(address, "http://%[-a-zA-Z0-9.]%s", host, path);
}
if(0 == host[0] || -1 == port) {
sscanf(address, "%[-a-zA-Z0-9.]%s", host, path);
}
if(0 == host[0] || -1 == port) {
printf("Wrong address!\n");
return 1;
}
if(0 == path[0]) {
path[0] = '/';
path[1] = 0;
}
sprintf(spec, "tcp:%s:%d", host, port);
Transport transport;
transport.start();
Connection *connection = NULL;
HTTPPacketFactory factory;
HTTPStreamer streamer(&factory);
connection = transport.connect(spec, &streamer);
if (NULL == connection) {
printf("Failed to connect server %s\n", spec);
exit(1);
}
HTTPPacket *requst = new HTTPPacket;
requst->setMethod(HTTPPacket::HM_GET);
requst->setURI(path);
requst->addHeader("Accept", "*/*");
requst->addHeader("Connection", "Keep-Alive");
requst->addHeader("Host", (const char*)(spec+4));
Packet *ret = connection->sendPacket(requst);
HTTPPacket *reply = NULL;
if (NULL != ret && ret->isRegularPacket()
&& (reply = dynamic_cast<HTTPPacket*>(ret)))
{
printf("------------reply from '%s' ----------\r\n", address);
printf("%s %d %s\r\n", reply->getVersion() ? "HTTP/1.1" : "HTTP/1.0",
reply->getStatusCode(), reply->getReasonPhrase());
for (HTTPPacket::ConstHeaderIterator it = reply->headerBegin();
it != reply->headerEnd(); it ++)
{
printf("%s: %s\r\n", it->first, it->second);
}
printf("\r\n");
if (reply->getBody()) {
fwrite(reply->getBody(), 1, reply->getBodyLen(), stdout);
}
printf("\n-----------end of reply-------------------\n");
} else {
printf("Fail to get reply from '%s' ----------\r\n", address);
ControlPacket *cmd = dynamic_cast<ControlPacket*>(ret);
if (cmd) {
printf("%s", cmd->what());
}
}
connection->subRef();
transport.stop();
transport.wait();
return 0;
}