コード例 #1
0
ファイル: inout.c プロジェクト: Unvanquished/daemonmap
void Broadcast_Shutdown(){
	if ( brdcst_socket ) {
		Sys_Printf( "Disconnecting\n" );
		Net_Disconnect( brdcst_socket );
		brdcst_socket = NULL;
	}
}
コード例 #2
0
ファイル: watchbsp.cpp プロジェクト: TTimo/GtkRadiant
void CWatchBSP::Reset(){
	if ( m_pInSocket ) {
		Net_Disconnect( m_pInSocket );
		m_pInSocket = NULL;
	}
	if ( m_pListenSocket ) {
		Net_Disconnect( m_pListenSocket );
		m_pListenSocket = NULL;
	}
	if ( m_xmlInputBuffer ) {
		xmlFreeParserInputBuffer( m_xmlInputBuffer );
		m_xmlInputBuffer = NULL;
	}
	if ( m_xmlParserCtxt ) {
		xmlFreeParserCtxt( m_xmlParserCtxt );
		m_xmlParserCtxt = NULL;
	}

	m_eState = EIdle;
}
コード例 #3
0
ファイル: inout.c プロジェクト: Asvarox/Unvanquished
void Broadcast_Shutdown(void)
{
#if defined(USE_XML)
	if(brdcst_socket)
	{
		Sys_Printf("Disconnecting\n");
		Net_Disconnect(brdcst_socket);
		brdcst_socket = NULL;
	}
#endif
}
コード例 #4
0
ファイル: irc.c プロジェクト: mintux/aqu4bot
Bool IRC_Quit(const char *QuitMSG)
{
	if (SocketDescriptor)
	{
		if (QuitMSG)
		{
			char OutBuf[2048];
			
			snprintf(OutBuf, sizeof OutBuf, "QUIT :%s\r\n", QuitMSG);
			Net_Write(SocketDescriptor, OutBuf);
		}
		else Net_Write(SocketDescriptor, "QUIT :aqu4bot " BOT_VERSION " shutting down.\r\n");
	}
	
	if (Net_Disconnect(SocketDescriptor))
	{
		SocketDescriptor = 0;
		return true;
	}
	
	return false;
}
コード例 #5
0
ファイル: watchbsp.cpp プロジェクト: TTimo/GtkRadiant
void CWatchBSP::RoutineProcessing(){
	// used for select()
#ifdef _WIN32
	TIMEVAL tout = { 0, 0 };
#endif
#if defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __APPLE__ )
	timeval tout;
	tout.tv_sec = 0;
	tout.tv_usec = 0;
#endif

	switch ( m_eState )
	{
	case EBeginStep:
		// timeout: if we don't get an incoming connection fast enough, go back to idle
		if ( g_timer_elapsed( m_pTimer, NULL ) > g_PrefsDlg.m_iTimeout ) {
			gtk_MessageBox( g_pParentWnd->m_pWidget, _( "The connection timed out, assuming the BSP process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs." ), _( "BSP process monitoring" ), MB_OK );
			Reset();
			if ( m_bBSPPlugin ) {
				// status == 1 : didn't get the connection
				g_BSPFrontendTable.m_pfnEndListen( 1 );
			}
			break;
		}
#ifdef _DEBUG
		// some debug checks
		if ( !m_pListenSocket ) {
			Sys_FPrintf( SYS_ERR, "ERROR: m_pListenSocket == NULL in CWatchBSP::RoutineProcessing EBeginStep state\n" );
			Reset();
			break;
		}
#endif
		// we are not connected yet, accept any incoming connection
		m_pInSocket = Net_Accept( m_pListenSocket );
		if ( m_pInSocket ) {
			Sys_Printf( "Connected.\n" );
			// prepare the message info struct for diving in
			memset( &m_message_info, 0, sizeof( message_info_s ) );
			// a dumb flag to make sure we init the push parser context when first getting a msg
			m_eState = EWatching;
		}
		break;

	case EWatching:
#ifdef _DEBUG
		// some debug checks
		if ( !m_pInSocket ) {
			Sys_FPrintf( SYS_ERR, "ERROR: m_pInSocket == NULL in CWatchBSP::RoutineProcessing EWatching state\n" );
			Reset();
			break;
		}
#endif
		// select() will identify if the socket needs an update
		// if the socket is identified that means there's either a message or the connection has been closed/reset/terminated
		fd_set readfds;
		int ret;
		FD_ZERO( &readfds );
		FD_SET( ( (unsigned int)m_pInSocket->socket ), &readfds );
		// from select man page:
		// n is the highest-numbered descriptor in any of the three sets, plus 1
		// (no use on windows)
		ret = select( m_pInSocket->socket + 1, &readfds, NULL, NULL, &tout );
		if ( ret == SOCKET_ERROR ) {
			Sys_FPrintf( SYS_WRN, "WARNING: SOCKET_ERROR in CWatchBSP::RoutineProcessing\n" );
			Sys_Printf( "Terminating the connection.\n" );
			Reset();
			break;
		}
		if ( ret == 1 ) {
			// the socket has been identified, there's something (message or disconnection)
			// see if there's anything in input
			ret = Net_Receive( m_pInSocket, &msg );
			if ( ret > 0 ) {
				//        unsigned int size = msg.size; //++timo just a check
				g_strlcpy( m_xmlBuf, NMSG_ReadString( &msg ), sizeof( m_xmlBuf) );
				if ( m_xmlParserCtxt == NULL ) {
					m_xmlParserCtxt = xmlCreatePushParserCtxt( &saxParser, &m_message_info, m_xmlBuf, strlen( m_xmlBuf ), NULL );
					if ( m_xmlParserCtxt == NULL ) {
						Sys_FPrintf( SYS_ERR, "Failed to create the XML parser (incoming stream began with: %s)\n", m_xmlBuf );
						Reset();
						break;
					}
				}
				else
				{
					xmlParseChunk( m_xmlParserCtxt, m_xmlBuf, strlen( m_xmlBuf ), 0 );
				}
			}
			else
			{
				// error or connection closed/reset
				// NOTE: if we get an error down the XML stream we don't reach here
				Net_Disconnect( m_pInSocket );
				m_pInSocket = NULL;
				Sys_Printf( "Connection closed.\n" );
				if ( m_bBSPPlugin ) {
					// let the BSP plugin know that the job is done
					g_BSPFrontendTable.m_pfnEndListen( 0 );
				}

				Reset();

				// move to next step or finish
				m_iCurrentStep++;
				if ( m_iCurrentStep < m_pCmd->len ) {
					DoEBeginStep();
					break;
				}

				// launch the engine .. OMG
				if ( g_PrefsDlg.m_bRunQuake ) {
					// do we enter sleep mode before?
					if ( g_PrefsDlg.m_bDoSleep ) {
						Sys_Printf( "Going into sleep mode..\n" );
						g_pParentWnd->OnSleep();
					}
					Sys_Printf( "Running engine...\n" );
					RunQuake();
				}
			}
		}
		break;
	default:
		break;
	}
}
コード例 #6
0
ファイル: NetscanJNI.c プロジェクト: imr/Electric8
JNIEXPORT jint JNICALL Java_com_sun_electric_tool_simulation_test_NetscanJNI_net_1disconnect
  (JNIEnv *env, jclass cls)
{
  return Net_Disconnect();
}