FFFTPのソースコードです。
修订版 | 66613203e90b0402574ce35f6cf160adc5057db1 (tree) |
---|---|
时间 | 2012-04-21 20:03:18 |
作者 | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Change intervals between keep alive packets.
@@ -38,6 +38,8 @@ | ||
38 | 38 | // IPv6対応 |
39 | 39 | //#include <winsock.h> |
40 | 40 | #include <winsock2.h> |
41 | +// 切断対策 | |
42 | +#include <mstcpip.h> | |
41 | 43 | #include <windowsx.h> |
42 | 44 | #include <commctrl.h> |
43 | 45 |
@@ -102,6 +104,8 @@ extern int FwallLower; | ||
102 | 104 | extern int FwallDelimiter; |
103 | 105 | extern int PasvDefault; |
104 | 106 | extern int QuickAnonymous; |
107 | +// 切断対策 | |
108 | +extern int TimeOut; | |
105 | 109 | |
106 | 110 | /*===== ローカルなワーク =====*/ |
107 | 111 |
@@ -1437,6 +1441,8 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char | ||
1437 | 1441 | static const char *SiteTbl[4] = { "SITE", "site", "OPEN", "open" }; |
1438 | 1442 | char TmpBuf[ONELINE_BUF_SIZE]; |
1439 | 1443 | struct linger LingerOpt; |
1444 | + struct tcp_keepalive KeepAlive; | |
1445 | + DWORD dwTmp; | |
1440 | 1446 | |
1441 | 1447 | // 暗号化通信対応 |
1442 | 1448 | ContSock = INVALID_SOCKET; |
@@ -1510,6 +1516,12 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char | ||
1510 | 1516 | Flg = 1; |
1511 | 1517 | if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR) |
1512 | 1518 | ReportWSError("setsockopt", WSAGetLastError()); |
1519 | + // 切断対策 | |
1520 | + KeepAlive.onoff = 1; | |
1521 | + KeepAlive.keepalivetime = TimeOut * 1000; | |
1522 | + KeepAlive.keepaliveinterval = 1000; | |
1523 | + if(WSAIoctl(ContSock, SIO_KEEPALIVE_VALS, &KeepAlive, sizeof(struct tcp_keepalive), NULL, 0, &dwTmp, NULL, NULL) == SOCKET_ERROR) | |
1524 | + ReportWSError("WSAIoctl", WSAGetLastError()); | |
1513 | 1525 | LingerOpt.l_onoff = 1; |
1514 | 1526 | LingerOpt.l_linger = 90; |
1515 | 1527 | if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR) |