cvs diff -u source\teraterm\commlib.c release\TERATERM.INI source\ttset\ttset.c source\common\tttypes.h source\teraterm\vtwin.cpp (ディレクトリ C:\usr\cvs\teraterm\ 内) Index: source/teraterm/commlib.c =================================================================== RCS file: /cvsroot/ttssh2/teraterm/source/teraterm/commlib.c,v retrieving revision 1.3 diff -u -r1.3 commlib.c --- source/teraterm/commlib.c 4 Jan 2007 15:11:44 -0000 1.3 +++ source/teraterm/commlib.c 11 Jan 2007 12:24:10 -0000 @@ -51,6 +51,14 @@ Psetsockopt(cv->s,(int)SOL_SOCKET,SO_OOBINLINE,(char FAR *)&BBuf,sizeof(BBuf)); /* set asynchronous mode */ PWSAAsyncSelect(cv->s,cv->HWin,WM_USER_COMMOPEN, FD_CONNECT); + + // ホストへの接続中に一定時間立つと、強制的にソケットをクローズして、 + // 接続処理をキャンセルさせる。値が0の場合は何もしない。 + // (2007.1.11 yutaka) + if (*cv->ConnetingTimeout > 0) { + SetTimer(cv->HWin, IdCancelConnectTimer, *cv->ConnetingTimeout * 1000, NULL); + } + /* WM_USER_COMMOPEN occurs, CommOpen is called, then CommStart is called */ Err = Pconnect(cv->s, cv->res->ai_addr, cv->res->ai_addrlen); if (Err != 0) { @@ -342,6 +350,7 @@ cv->TelAutoDetect = TRUE; /* TTPLUG */ cv->Locale = ts->Locale; cv->CodePage = &ts->CodePage; + cv->ConnetingTimeout = &ts->ConnectingTimeout; if ((ts->PortType!=IdSerial) && (strlen(ts->HostName)==0)) { @@ -706,6 +715,12 @@ if (! cv->Open ) return; if ( cv->Ready ) return; + + // キャンセルタイマがあれば取り消す。ただし、この時点で WM_TIMER が送られている可能性はある。 + if (*cv->ConnetingTimeout > 0) { + KillTimer(cv->HWin, IdCancelConnectTimer); + } + switch (cv->PortType) { case IdTCPIP: ErrMsg[0] = 0; Index: source/teraterm/vtwin.cpp =================================================================== RCS file: /cvsroot/ttssh2/teraterm/source/teraterm/vtwin.cpp,v retrieving revision 1.44 diff -u -r1.44 vtwin.cpp --- source/teraterm/vtwin.cpp 4 Jan 2007 15:11:44 -0000 1.44 +++ source/teraterm/vtwin.cpp 11 Jan 2007 12:24:11 -0000 @@ -1884,6 +1884,15 @@ (Point.y < 0) || (Point.y >= ScreenHeight)) ::PostMessage(HVTWin,WM_MOUSEMOVE,MK_LBUTTON,MAKELONG(Point.x,Point.y)); return; + } + else if (nIDEvent == IdCancelConnectTimer) + { + // まだ接続が完了していなければ、ソケットを強制クローズ。 + // CloseSocket()を呼びたいが、ここからは呼べないので、直接Win32APIをコールする。 + if (!cv.Ready) { + closesocket(cv.s); + //::PostMessage(HVTWin, WM_USER_COMMNOTIFY, 0, FD_CLOSE); + } } ::KillTimer(HVTWin, nIDEvent); Index: release/TERATERM.INI =================================================================== RCS file: /cvsroot/ttssh2/teraterm/release/TERATERM.INI,v retrieving revision 1.32 diff -u -r1.32 TERATERM.INI --- release/TERATERM.INI 7 Nov 2006 07:33:39 -0000 1.32 +++ release/TERATERM.INI 11 Jan 2007 12:24:11 -0000 @@ -29,6 +29,11 @@ ; Language (English/Japanese/Russian) Language= +; Connecting timeout value(per seconds). No action if the value is zero. +; Connecting socket could be canceled after the value timeout if the value is greater than zero. +; The default value is zero(depends on Windows TCP/IP stack implementation). +ConnectingTimeout = 0 + ; pasting string by clicking mouse right button disabled DisablePasteMouseRButton=off Index: source/ttset/ttset.c =================================================================== RCS file: /cvsroot/ttssh2/teraterm/source/ttset/ttset.c,v retrieving revision 1.19 diff -u -r1.19 ttset.c --- source/ttset/ttset.c 23 Nov 2006 02:19:16 -0000 1.19 +++ source/ttset/ttset.c 11 Jan 2007 12:24:12 -0000 @@ -941,6 +941,9 @@ ts->DisablePasteMouseRButton = GetOnOff(Section,"DisablePasteMouseRButton",FName,FALSE); + // WinSock connecting timeout value (2007.1.11 yutaka) + ts->ConnectingTimeout = GetPrivateProfileInt(Section,"ConnectingTimeout",0,FName); + // mouse cursor GetPrivateProfileString(Section,"MouseCursor","IBEAM", Temp,sizeof(Temp),FName); @@ -1115,6 +1118,7 @@ WritePrivateProfileString(Section,"KanjiOut",Temp,FName); // new configuration + WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout); WriteOnOff(Section, "DisablePasteMouseRButton", FName, ts->DisablePasteMouseRButton); WriteOnOff(Section, "EnableContinuedLineCopy", FName, ts->EnableContinuedLineCopy); WritePrivateProfileString(Section,"MouseCursor", ts->MouseCursorName, FName); @@ -2301,6 +2305,13 @@ ts->DuplicateSession = 1; } + else if (_strnicmp(Temp, "/TIMEOUT=", 9) == 0 ) { // Connecting Timeout value (2007.1.11. yutaka) + if (sscanf(&Temp[9],"%d",&pos)==1) { + if (pos >= 0) + ts->ConnectingTimeout = pos; + } + + } else if ( (Temp[0]!='/') && (strlen(Temp)>0) ) { if (JustAfterHost && Index: source/common/tttypes.h =================================================================== RCS file: /cvsroot/ttssh2/teraterm/source/common/tttypes.h,v retrieving revision 1.13 diff -u -r1.13 tttypes.h --- source/common/tttypes.h 23 Nov 2006 02:19:10 -0000 1.13 +++ source/common/tttypes.h 11 Jan 2007 12:24:12 -0000 @@ -13,6 +13,7 @@ #define IdCaretTimer 7 #define IdPrnStartTimer 8 #define IdPrnProcTimer 9 +#define IdCancelConnectTimer 10 // add (2007.1.10 yutaka) /* Window Id */ #define IdVT 1 @@ -350,6 +351,7 @@ char UILanguageFile[MAX_PATH]; char UIMsg[MAX_UIMSG]; #endif + int ConnectingTimeout; }; typedef struct tttset TTTSet, *PTTSet; @@ -710,6 +712,7 @@ #endif /* INET6 */ char *Locale; int *CodePage; + int *ConnetingTimeout; }TComVar; typedef TComVar far *PComVar; ***** CVS はコード 1 で終了しました *****