示例#1
0
// The "end" event that prints the final result
static void terminate( void * arg ){
    
    fprintf( stderr, "Total number of lines %d\n", sum );

    free( f );
    cleanupStream( gStream );
    stopEventLoop( gEventLoop );
}
示例#2
0
文件: Client.cpp 项目: 335/synergy
void
Client::handleConnectTimeout(const Event&, void*)
{
	cleanupTimer();
	cleanupConnecting();
	cleanupConnection();
	cleanupStream();
	LOG((CLOG_DEBUG1 "connection timed out"));
	sendConnectionFailedEvent("Timed out");
}
示例#3
0
文件: Client.cpp 项目: 335/synergy
void
Client::connect()
{
	if (m_stream != NULL) {
		return;
	}
	if (m_suspended) {
		m_connectOnResume = true;
		return;
	}

	try {
		// resolve the server hostname.  do this every time we connect
		// in case we couldn't resolve the address earlier or the address
		// has changed (which can happen frequently if this is a laptop
		// being shuttled between various networks).  patch by Brent
		// Priddy.
		m_serverAddress.resolve();
		
		// m_serverAddress will be null if the hostname address is not reolved
		if (m_serverAddress.getAddress() != NULL) {
		  // to help users troubleshoot, show server host name (issue: 60)
		  LOG((CLOG_NOTE "connecting to '%s': %s:%i", 
		  m_serverAddress.getHostname().c_str(),
		  ARCH->addrToString(m_serverAddress.getAddress()).c_str(),
		  m_serverAddress.getPort()));
		}

		// create the socket
		IDataSocket* socket = m_socketFactory->create(m_useSecureNetwork);
		m_socket = dynamic_cast<TCPSocket*>(socket);

		// filter socket messages, including a packetizing filter
		m_stream = socket;
		bool adopt = !m_useSecureNetwork;
		m_stream = new PacketStreamFilter(m_events, m_stream, adopt);

		// connect
		LOG((CLOG_DEBUG1 "connecting to server"));
		setupConnecting();
		setupTimer();
		socket->connect(m_serverAddress);
	}
	catch (XBase& e) {
		cleanupTimer();
		cleanupConnecting();
		cleanupStream();
		LOG((CLOG_DEBUG1 "connection failed"));
		sendConnectionFailedEvent(e.what());
		return;
	}
}
示例#4
0
文件: Client.cpp 项目: 335/synergy
void
Client::handleConnectionFailed(const Event& event, void*)
{
	IDataSocket::ConnectionFailedInfo* info =
		reinterpret_cast<IDataSocket::ConnectionFailedInfo*>(event.getData());

	cleanupTimer();
	cleanupConnecting();
	cleanupStream();
	LOG((CLOG_DEBUG1 "connection failed"));
	sendConnectionFailedEvent(info->m_what.c_str());
	delete info;
}
示例#5
0
文件: Client.cpp 项目: 335/synergy
void
Client::cleanupConnection()
{
	if (m_stream != NULL) {
		m_events->removeHandler(m_events->forIStream().inputReady(),
							m_stream->getEventTarget());
		m_events->removeHandler(m_events->forIStream().outputError(),
							m_stream->getEventTarget());
		m_events->removeHandler(m_events->forIStream().inputShutdown(),
							m_stream->getEventTarget());
		m_events->removeHandler(m_events->forIStream().outputShutdown(),
							m_stream->getEventTarget());
		m_events->removeHandler(m_events->forISocket().disconnected(),
							m_stream->getEventTarget());
		m_events->removeHandler(m_events->forISocket().stopRetry(),
								m_stream->getEventTarget());
		cleanupStream();
	}
}
示例#6
0
 ~MQChannelElement() {
     cleanupStream();
 }