とりあえず、再現用のソースです。サーバ側は何でもいい(いらない)と思います。
原因や対策などは調べていません。
//- 以下、テストコード -//
#include <process.h>
#include "DxLib.h"
bool quit_thread;
int nh = -1;
unsigned int WINAPI MyThread( void* )
{
IPDATA Ip = { 192, 168, 0, 1 };
while ( 1 ) {
if ( (nh = ConnectNetWork( Ip, 9850 )) != -1 ) {
break;
}
if ( quit_thread == true )
break;
Sleep( 500 );
}
_endthreadex( 0 );
return 0;
}
int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
ChangeWindowMode( TRUE );
SetDoubleStartValidFlag( TRUE );
SetAlwaysRunFlag( TRUE );
SetWindowText( "DxLib:" DXLIB_VERSION_STR );
if ( DxLib_Init( ) == -1 ) return -1;
int white = GetColor( 255, 255, 255 );
quit_thread = false;
unsigned int thread_id1;
HANDLE thread_handle1 = (HANDLE)_beginthreadex( NULL, 0, &MyThread, 0, 0, &thread_id1 );
SetDrawScreen( DX_SCREEN_BACK );
while ( ProcessMessage( ) == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 ) {
ClearDrawScreen( );
DrawFormatString( 0, 0, white, "TEST:%d", nh );
ScreenFlip( );
}
quit_thread = true;
WaitForSingleObject( thread_handle1, INFINITE );
CloseHandle( thread_handle1 );
CloseNetWork( nh );
DxLib_End( );
return 0;
}