initial commit

This commit is contained in:
Amazed 2019-06-18 15:48:29 +02:00
commit 58f8f19b0f
33 changed files with 1291 additions and 0 deletions

BIN
Debug/GCKMS.exe Normal file

Binary file not shown.

BIN
Debug/GCKMS.ilk Normal file

Binary file not shown.

BIN
Debug/GCKMS.obj Normal file

Binary file not shown.

BIN
Debug/GCKMS.pch Normal file

Binary file not shown.

BIN
Debug/GCKMS.pdb Normal file

Binary file not shown.

BIN
Debug/GCKMS.res Normal file

Binary file not shown.

BIN
Debug/GCKMSDlg.obj Normal file

Binary file not shown.

BIN
Debug/StdAfx.obj Normal file

Binary file not shown.

BIN
Debug/WSTCPS.obj Normal file

Binary file not shown.

BIN
Debug/WSUDPS.obj Normal file

Binary file not shown.

BIN
Debug/vc60.idb Normal file

Binary file not shown.

BIN
Debug/vc60.pdb Normal file

Binary file not shown.

BIN
GCKMS.APS Normal file

Binary file not shown.

60
GCKMS.clw Normal file
View File

@ -0,0 +1,60 @@
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=CGCKMSDlg
LastTemplate=CAsyncSocket
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "GCKMS.h"
ClassCount=4
Class1=CGCKMSApp
Class2=CGCKMSDlg
ResourceCount=2
Resource1=IDR_MAINFRAME
Class3=CWSUDPS
Class4=CWSTCPS
Resource2=IDD_GCKMS_DIALOG
[CLS:CGCKMSApp]
Type=0
HeaderFile=GCKMS.h
ImplementationFile=GCKMS.cpp
Filter=N
LastObject=CGCKMSApp
[CLS:CGCKMSDlg]
Type=0
HeaderFile=GCKMSDlg.h
ImplementationFile=GCKMSDlg.cpp
Filter=W
BaseClass=CDialog
VirtualFilter=dWC
LastObject=CGCKMSDlg
[DLG:IDD_GCKMS_DIALOG]
Type=1
Class=CGCKMSDlg
ControlCount=0
[CLS:CWSUDPS]
Type=0
HeaderFile=WSUDPS.h
ImplementationFile=WSUDPS.cpp
BaseClass=CAsyncSocket
Filter=N
VirtualFilter=q
LastObject=CWSUDPS
[CLS:CWSTCPS]
Type=0
HeaderFile=WSTCPS.h
ImplementationFile=WSTCPS.cpp
BaseClass=CAsyncSocket
Filter=N
VirtualFilter=q
LastObject=CWSTCPS

45
GCKMS.cpp Normal file
View File

@ -0,0 +1,45 @@
// GCKMS.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "GCKMS.h"
#include "GCKMSDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGCKMSApp
BEGIN_MESSAGE_MAP(CGCKMSApp, CWinApp)
//{{AFX_MSG_MAP(CGCKMSApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGCKMSApp construction
CGCKMSApp::CGCKMSApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CGCKMSApp object
CGCKMSApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CGCKMSApp initialization
BOOL CGCKMSApp::InitInstance()
{
CGCKMSDlg dlg;
m_pMainWnd = &dlg;
AfxSocketInit();
dlg.DoModal();
return FALSE;
}

158
GCKMS.dsp Normal file
View File

@ -0,0 +1,158 @@
# Microsoft Developer Studio Project File - Name="GCKMS" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=GCKMS - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "GCKMS.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "GCKMS.mak" CFG="GCKMS - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "GCKMS - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "GCKMS - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "GCKMS - Win32 Release"
# PROP BASE Use_MFC 5
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "GCKMS - Win32 Debug"
# PROP BASE Use_MFC 5
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "GCKMS - Win32 Release"
# Name "GCKMS - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\GCKMS.cpp
# End Source File
# Begin Source File
SOURCE=.\GCKMS.rc
# End Source File
# Begin Source File
SOURCE=.\GCKMSDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\WSTCPS.cpp
# End Source File
# Begin Source File
SOURCE=.\WSUDPS.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\GCKMS.h
# End Source File
# Begin Source File
SOURCE=.\GCKMSDlg.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\WSTCPS.h
# End Source File
# Begin Source File
SOURCE=.\WSUDPS.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\GCKMS.ico
# End Source File
# Begin Source File
SOURCE=.\res\GCKMS.rc2
# End Source File
# End Group
# End Target
# End Project

29
GCKMS.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "GCKMS"=".\GCKMS.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

47
GCKMS.h Normal file
View File

@ -0,0 +1,47 @@
// GCKMS.h : main header file for the GCKMS application
//
#if !defined(AFX_GCKMS_H__1EFE3324_8581_4FF8_81C9_36AC4815918D__INCLUDED_)
#define AFX_GCKMS_H__1EFE3324_8581_4FF8_81C9_36AC4815918D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CGCKMSApp:
// See GCKMS.cpp for the implementation of this class
//
class CGCKMSApp : public CWinApp
{
public:
CGCKMSApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGCKMSApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CGCKMSApp)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GCKMS_H__1EFE3324_8581_4FF8_81C9_36AC4815918D__INCLUDED_)

BIN
GCKMS.ncb Normal file

Binary file not shown.

BIN
GCKMS.opt Normal file

Binary file not shown.

37
GCKMS.plg Normal file
View File

@ -0,0 +1,37 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: GCKMS - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\XT\LOCALS~1\Temp\RSP1EC.tmp" with contents
[
/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/GCKMS.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Documents and Settings\XT\My Documents\ChateX\ChateX source code\GCKMS\GCKMSDlg.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\XT\LOCALS~1\Temp\RSP1EC.tmp"
Creating temporary file "C:\DOCUME~1\XT\LOCALS~1\Temp\RSP1ED.tmp" with contents
[
/nologo /subsystem:windows /incremental:yes /pdb:"Debug/GCKMS.pdb" /debug /machine:I386 /out:"Debug/GCKMS.exe" /pdbtype:sept
".\Debug\GCKMS.obj"
".\Debug\GCKMSDlg.obj"
".\Debug\StdAfx.obj"
".\Debug\WSTCPS.obj"
".\Debug\WSUDPS.obj"
".\Debug\GCKMS.res"
]
Creating command line "link.exe @C:\DOCUME~1\XT\LOCALS~1\Temp\RSP1ED.tmp"
<h3>Output Window</h3>
Compiling...
GCKMSDlg.cpp
Linking...
<h3>Results</h3>
GCKMS.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

182
GCKMS.rc Normal file
View File

@ -0,0 +1,182 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\GCKMS.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\GCKMS.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_GCKMS_DIALOG DIALOGEX 0, 0, 280, 140
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "GCKMS"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "GCKMS\0"
VALUE "FileVersion", "1, 0, 0, 0\0"
VALUE "InternalName", "GCKMS\0"
VALUE "OriginalFilename", "GCKMS.EXE\0"
VALUE "ProductName", "GCKMS\0"
VALUE "ProductVersion", "1, 0, 0, 0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_GCKMS_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 273
TOPMARGIN, 7
BOTTOMMARGIN, 133
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\GCKMS.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

358
GCKMSDlg.cpp Normal file
View File

@ -0,0 +1,358 @@
// GCKMSDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GCKMS.h"
#include "GCKMSDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGCKMSDlg dialog
CGCKMSDlg::CGCKMSDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGCKMSDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGCKMSDlg)
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGCKMSDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGCKMSDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGCKMSDlg, CDialog)
//{{AFX_MSG_MAP(CGCKMSDlg)
ON_WM_CLOSE()
ON_WM_ENDSESSION()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGCKMSDlg message handlers
void CGCKMSDlg::OnClose()
{
int i;
if(m_ID_list.empty() == FALSE)
{
for(i = 0; i < m_ID_list.size(); i ++)
{
KillTimer(m_ID_list[i] + 1000);
}
}
m_ID_list.clear();
m_IP_list.clear();
m_port_list.clear();
m_wsUDPS.Close();
for(i = 0; i < m_wsTCPS_list.size(); i ++)
{
m_wsTCPS_list[i]->m_Data = "";
m_wsTCPS_list[i]->m_dta.clear();
m_wsTCPS_list[i]->ShutDown(2);
m_wsTCPS_list[i]->Close();
delete m_wsTCPS_list[i];
}
m_wsTCPS_list.clear();
DestroyWindow();
CDialog::OnClose();
}
void CGCKMSDlg::OnCancel()
{
OnClose();
}
void CGCKMSDlg::OnOK()
{
}
void CGCKMSDlg::OnEndSession(BOOL bEnding)
{
OnClose();
}
BOOL CGCKMSDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString txt;
CWSTCPS *wsTCPS;
SetIcon(m_hIcon, TRUE);
if(m_wsUDPS.Create(27900, SOCK_DGRAM, FD_READ) != FALSE)
{
txt = " - UDP server running";
}
// test.Create(111, SOCK_DGRAM, FD_READ);
// test.SendTo("\\heartbeat\\8911\\gamename\\giants", 31, 27900, "gckms.no-ip.org");
m_wsTCPS_list.push_back(wsTCPS);
m_wsTCPS_list[0] = new CWSTCPS;
if(m_wsTCPS_list[0]->Create(28900, SOCK_STREAM, FD_ACCEPT | FD_READ | FD_CLOSE) != FALSE)
{
if(m_wsTCPS_list[0]->Listen() != FALSE)
{
SetTimer(ID_TCPS_TIMER, 30000, NULL);
if(txt == "")
{
txt = " - TCP server running";
}
else
{
txt = txt + " | TCP server running";
}
}
}
SetWindowText("GCKMS" + txt);
return TRUE;
}
void CGCKMSDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CGCKMSDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGCKMSDlg::OnUDPS_Receive(int nErrorCode)
{
if(nErrorCode == 0)
{
DWORD rcv;
int rcv2;
CString IP;
UINT port;
char *dta;
CString txt;
m_wsUDPS.IOCtl(FIONREAD, &rcv);
dta = new char[rcv + 1];
rcv2 = m_wsUDPS.ReceiveFrom(dta, rcv, IP, port);
dta[rcv2] = '\0';
txt = dta;
delete [] dta;
if(IP.Left(7) == "192.168")
{
IP = inet_ntoa(*((struct in_addr*)gethostbyname("gckms.no-ip.org")->h_addr_list[0]));
}
if(m_IP_list.size() < 1000 && (txt.Left(1) == "0" || txt.Left(1) == "1"))
{
if(m_ID_list.empty() != FALSE && txt.Left(1) == "0")
{
int i;
m_ID_list.push_back(0);
m_IP_list.push_back(IP);
m_port_list.push_back(atoi(txt.Mid(1)));
SetTimer(1000, 360000, NULL);
for(i = 1; i < m_wsTCPS_list.size(); i ++)
{
m_wsTCPS_list[i]->Send("00¬" + IP + "¬" + txt.Mid(1) + '\0', IP.GetLength() + txt.Mid(1).GetLength() + 5);
}
}
else
{
int i;
BOOL isIPnP;
isIPnP = FALSE;
for(i = 0; i < m_ID_list.size(); i ++)
{
if(m_IP_list[i] == IP && m_port_list[i] == atoi(txt.Mid(1)))
{
KillTimer(m_ID_list[i]);
SetTimer(m_ID_list[i] + 1000, 360000, NULL);
if(txt.Left(1) == "1")
{
int j;
CString txt2;
txt2.Format("%d", m_ID_list[i]);
for(j = 1; j < m_wsTCPS_list.size(); j ++)
{
m_wsTCPS_list[j]->Send("1" + txt2 + '\0', txt2.GetLength() + 2);
}
}
isIPnP = TRUE;
break;
}
}
if(isIPnP == FALSE && txt.Left(1) == "0")
{
int j;
BOOL isID;
for(i = 0; i <= 999; i ++)
{
isID = FALSE;
for(j = 0; j < m_ID_list.size(); j ++)
{
if(m_ID_list[j] == i)
{
isID = TRUE;
break;
}
}
if(isID == FALSE)
{
CString txt2;
m_ID_list.push_back(i);
m_IP_list.push_back(IP);
m_port_list.push_back(atoi(txt.Mid(1)));
SetTimer(i + 1000, 360000, NULL);
txt2.Format("%d", i);
for(j = 1; j < m_wsTCPS_list.size(); j ++)
{
m_wsTCPS_list[j]->Send("0" + txt2 + "¬" + IP + "¬" + txt.Mid(1) + '\0', txt2.GetLength() + IP.GetLength() + txt.Mid(1).GetLength() + 4);
}
break;
}
}
}
}
if(txt.Left(1) == "0")
{
m_wsUDPS.SendTo("\\status\\", 8, port, IP);
}
}
}
}
void CGCKMSDlg::OnTCPS_Accept(int nErrorCode)
{
if(m_wsTCPS_list.size() < 1001)
{
CWSTCPS *wsTCPS;
m_wsTCPS_list.push_back(wsTCPS);
m_wsTCPS_list.back() = new CWSTCPS;
m_wsTCPS_list[0]->Accept(*m_wsTCPS_list.back());
if(m_IP_list.empty() == FALSE)
{
int i;
std::string txt;
CString txt2;
CString txt3;
std::vector <char> dta;
for(i = 0; i < m_ID_list.size(); i ++)
{
txt2.Format("%d", m_ID_list[i]);
txt3.Format("%d", m_port_list[i]);
txt.append("0" + txt2 + "¬" + m_IP_list[i] + "¬" + txt3);
dta.insert(dta.end(), txt.begin(), txt.end());
txt = "";
dta.push_back('\0');
}
m_wsTCPS_list.back()->Send(&dta[0], dta.size());
dta.clear();
}
}
}
void CGCKMSDlg::OnTCPS_Receive(int nErrorCode, CWSTCPS *socket)
{
if(nErrorCode == 0)
{
DWORD rcv;
int rcv2;
int i;
char *dta;
((CWSTCPS*)socket)->IOCtl(FIONREAD, &rcv);
dta = new char[rcv];
rcv2 = ((CWSTCPS*)socket)->Receive(dta, rcv);
for(i = 0; i < rcv2; i ++)
{
if(dta[i] != '\0')
{
int j;
for(j = 1; j < m_wsTCPS_list.size(); j ++)
{
if(m_wsTCPS_list[j] == socket)
{
m_wsTCPS_list[j]->m_Data = "";
m_wsTCPS_list[j]->m_dta.clear();
m_wsTCPS_list[j]->ShutDown(2);
m_wsTCPS_list[j]->Close();
delete m_wsTCPS_list[j];
m_wsTCPS_list.erase(&m_wsTCPS_list[j]);
delete [] dta;
return;
}
}
}
}
delete [] dta;
}
}
void CGCKMSDlg::OnTCPS_Close(int nErrorCode, CWSTCPS *socket)
{
int i;
for(i = 1; i < m_wsTCPS_list.size(); i ++)
{
if(m_wsTCPS_list[i] == socket)
{
m_wsTCPS_list[i]->m_Data = "";
m_wsTCPS_list[i]->m_dta.clear();
m_wsTCPS_list[i]->ShutDown(2);
m_wsTCPS_list[i]->Close();
delete m_wsTCPS_list[i];
m_wsTCPS_list.erase(&m_wsTCPS_list[i]);
break;
}
}
}
void CGCKMSDlg::OnTimer(UINT nIDEvent)
{
int i;
for(i = 0; i < m_ID_list.size(); i ++)
{
if(m_ID_list[i] + 1000 == nIDEvent)
{
int j;
CString txt2;
KillTimer(m_ID_list[i] + 1000);
txt2.Format("%d", m_ID_list[i]);
for(j = 1; j < m_wsTCPS_list.size(); j ++)
{
m_wsTCPS_list[j]->Send("2" + txt2 + '\0', txt2.GetLength() + 2);
}
m_ID_list.erase(&m_ID_list[i]);
m_IP_list.erase(&m_IP_list[i]);
m_port_list.erase(&m_port_list[i]);
break;
}
}
if(nIDEvent == ID_TCPS_TIMER)
{
for(i = 1; i < m_wsTCPS_list.size(); i ++)
{
char dta[1];
dta[0] = '\0';
m_wsTCPS_list[i]->Send(dta, 1);
}
}
CDialog::OnTimer(nIDEvent);
}

67
GCKMSDlg.h Normal file
View File

@ -0,0 +1,67 @@
// GCKMSDlg.h : header file
//
#if !defined(AFX_GCKMSDLG_H__8F032D5E_A4C7_44F9_8330_C36FD40B0F2C__INCLUDED_)
#define AFX_GCKMSDLG_H__8F032D5E_A4C7_44F9_8330_C36FD40B0F2C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CGCKMSDlg dialog
#include "vector"
#include "WSUDPS.h"
#include "WSTCPS.h"
class CGCKMSDlg : public CDialog
{
// Construction
public:
void OnUDPS_Receive(int nErrorCode);
void OnTCPS_Accept(int nErrorCode);
void OnTCPS_Receive(int nErrorCode, CWSTCPS *socket);
void OnTCPS_Close(int nErrorCode, CWSTCPS *socket);
CGCKMSDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CGCKMSDlg)
enum { IDD = IDD_GCKMS_DIALOG };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGCKMSDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CGCKMSDlg)
afx_msg void OnClose();
virtual void OnCancel();
virtual void OnOK();
afx_msg void OnEndSession(BOOL bEnding);
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CWSUDPS m_wsUDPS;
// CWSUDPS test;
std::vector <CWSTCPS*> m_wsTCPS_list;
std::vector <int> m_ID_list;
std::vector <CString> m_IP_list;
std::vector <UINT> m_port_list;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GCKMSDLG_H__8F032D5E_A4C7_44F9_8330_C36FD40B0F2C__INCLUDED_)

8
StdAfx.cpp Normal file
View File

@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// GCKMS.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

27
StdAfx.h Normal file
View File

@ -0,0 +1,27 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__FE213F4D_84B8_4047_8CCA_06BB2C846C10__INCLUDED_)
#define AFX_STDAFX_H__FE213F4D_84B8_4047_8CCA_06BB2C846C10__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h> // MFC socket extensions
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__FE213F4D_84B8_4047_8CCA_06BB2C846C10__INCLUDED_)

100
WSTCPS.cpp Normal file
View File

@ -0,0 +1,100 @@
// WSTCPS.cpp : implementation file
//
#include "stdafx.h"
#include "GCKMS.h"
#include "GCKMSDlg.h"
#include "WSTCPS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWSTCPS
CWSTCPS::CWSTCPS()
{
}
CWSTCPS::~CWSTCPS()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CWSTCPS, CAsyncSocket)
//{{AFX_MSG_MAP(CWSTCPS)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CWSTCPS member functions
void CWSTCPS::OnAccept(int nErrorCode)
{
((CGCKMSDlg*)AfxGetMainWnd())->OnTCPS_Accept(nErrorCode);
CAsyncSocket::OnAccept(nErrorCode);
}
void CWSTCPS::OnReceive(int nErrorCode)
{
((CGCKMSDlg*)AfxGetMainWnd())->OnTCPS_Receive(nErrorCode, this);
CAsyncSocket::OnReceive(nErrorCode);
}
void CWSTCPS::OnClose(int nErrorCode)
{
((CGCKMSDlg*)AfxGetMainWnd())->OnTCPS_Close(nErrorCode, this);
CAsyncSocket::OnClose(nErrorCode);
}
void CWSTCPS::OnSend(int nErrorCode)
{
if(nErrorCode == 0)
{
if(m_dta.empty() == FALSE)
{
int i;
int ns;
char *dta;
dta = new char[m_dta.size()];
for(i = 0; i < m_dta.size(); i ++)
{
dta[i] = m_dta[i];
}
ns = m_dta.size();
m_dta.clear();
Send(dta, ns);
delete [] dta;
}
}
CAsyncSocket::OnSend(nErrorCode);
}
int CWSTCPS::Send(const void* lpBuf, int nBufLen, int nFlags)
{
int i;
int ns;
char *dta;
dta = new char[nBufLen];
memcpy(dta, lpBuf, nBufLen);
for(i = 0; i < nBufLen; i ++)
{
m_dta.push_back(dta[i]);
}
delete [] dta;
ns = CAsyncSocket::Send(lpBuf, nBufLen, nFlags);
if(ns != SOCKET_ERROR)
{
if(m_dta.empty() == FALSE)
{
m_dta.clear();
}
}
return ns;
}

53
WSTCPS.h Normal file
View File

@ -0,0 +1,53 @@
#if !defined(AFX_WSTCPS_H__81D06561_4259_467F_BB88_E1DCEB1FAF3F__INCLUDED_)
#define AFX_WSTCPS_H__81D06561_4259_467F_BB88_E1DCEB1FAF3F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// WSTCPS.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWSTCPS command target
class CWSTCPS : public CAsyncSocket
{
// Attributes
public:
// Operations
public:
CWSTCPS();
virtual ~CWSTCPS();
// Overrides
public:
CString m_Data;
std::vector <char> m_dta;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWSTCPS)
public:
virtual void OnAccept(int nErrorCode);
virtual void OnReceive(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnSend(int nErrorCode);
virtual int Send(const void* lpBuf, int nBufLen, int nFlags = 0);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CWSTCPS)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WSTCPS_H__81D06561_4259_467F_BB88_E1DCEB1FAF3F__INCLUDED_)

42
WSUDPS.cpp Normal file
View File

@ -0,0 +1,42 @@
// WSUDPS.cpp : implementation file
//
#include "stdafx.h"
#include "GCKMS.h"
#include "GCKMSDlg.h"
#include "WSUDPS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWSUDPS
CWSUDPS::CWSUDPS()
{
}
CWSUDPS::~CWSUDPS()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CWSUDPS, CAsyncSocket)
//{{AFX_MSG_MAP(CWSUDPS)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CWSUDPS member functions
void CWSUDPS::OnReceive(int nErrorCode)
{
((CGCKMSDlg*)AfxGetMainWnd())->OnUDPS_Receive(nErrorCode);
CAsyncSocket::OnReceive(nErrorCode);
}

45
WSUDPS.h Normal file
View File

@ -0,0 +1,45 @@
#if !defined(AFX_WSUDPS_H__8041C8E9_18CA_4A67_84E2_83189F3A0EAA__INCLUDED_)
#define AFX_WSUDPS_H__8041C8E9_18CA_4A67_84E2_83189F3A0EAA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// WSUDPS.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWSUDPS command target
class CWSUDPS : public CAsyncSocket
{
// Attributes
public:
// Operations
public:
CWSUDPS();
virtual ~CWSUDPS();
// Overrides
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWSUDPS)
public:
virtual void OnReceive(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CWSUDPS)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WSUDPS_H__8041C8E9_18CA_4A67_84E2_83189F3A0EAA__INCLUDED_)

BIN
res/GCKMS.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

13
res/GCKMS.rc2 Normal file
View File

@ -0,0 +1,13 @@
//
// GCKMS.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

20
resource.h Normal file
View File

@ -0,0 +1,20 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by GCKMS.rc
//
#define ID_TCPS_TIMER 101
#define IDD_GCKMS_DIALOG 102
#define IDP_SOCKETS_INIT_FAILED 103
#define IDR_MAINFRAME 128
#define IDC_LIST 2001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 2002
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif