UDP基础模板。读取时没有使用地址读取
This commit is contained in:
commit
7d0e60186c
UDPtext
.vs/UDPtext/v16
.suoBrowse.VC.db
ipch/AutoPCH
156985627882922f
3192709a22c3684a
77b2da7627ba8bed
7ade28accd28c1fb
af3b1e0f9cca4175
fb38de3c5bc50ce5
fbb33cec128ce1d0
fd9e10274e229b53
Debug
UDP.objUDPtext.exeUDPtext.exe.recipeUDPtext.ilkUDPtext.logUDPtext.pdb
UDP.cppUDP.hUDPtext.slnUDPtext.vcxprojUDPtext.vcxproj.filtersUDPtext.vcxproj.userUDPtext.tlog
CL.command.1.tlogCL.read.1.tlogCL.write.1.tlogUDPtext.lastbuildstatelink.command.1.tloglink.read.1.tloglink.write.1.tlog
UDPtext.vcxproj.FileListAbsolute.txtjsoncpp.objstdafx.objtran.objvc142.idbvc142.pdbjson
jsoncpp.cppstdafx.cppstdafx.htargetver.htran.cppUDPtext_shou
.vs/UDPtext/v16
.suoBrowse.VC.db
ipch/AutoPCH
156985627882922f
24a6306a8c5dd03b
3192709a22c3684a
77b2da7627ba8bed
7ade28accd28c1fb
af3b1e0f9cca4175
cbebbe323df8fa53
e878b2f1dc0bd4a7
fb38de3c5bc50ce5
fbb33cec128ce1d0
fd9e10274e229b53
Debug
UDP.objUDPtext.exeUDPtext.exe.recipeUDPtext.ilkUDPtext.logUDPtext.pdb
UDP.cppUDP.hUDPtext.slnUDPtext.vcxprojUDPtext.vcxproj.filtersUDPtext.vcxproj.userUDPtext.tlog
CL.command.1.tlogCL.read.1.tlogCL.write.1.tlogUDPtext.lastbuildstatelink.command.1.tloglink.read.1.tloglink.write.1.tlog
UDPtext.vcxproj.FileListAbsolute.txtjsoncpp.objstdafx.objtran.objvc142.idbvc142.pdbjson
jsoncpp.cppstdafx.cppstdafx.htargetver.htran.cpp
BIN
UDPtext/.vs/UDPtext/v16/.suo
Normal file
BIN
UDPtext/.vs/UDPtext/v16/.suo
Normal file
Binary file not shown.
BIN
UDPtext/.vs/UDPtext/v16/Browse.VC.db
Normal file
BIN
UDPtext/.vs/UDPtext/v16/Browse.VC.db
Normal file
Binary file not shown.
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/156985627882922f/UDP.ipch
Normal file
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/156985627882922f/UDP.ipch
Normal file
Binary file not shown.
Binary file not shown.
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/77b2da7627ba8bed/TRAN.ipch
Normal file
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/77b2da7627ba8bed/TRAN.ipch
Normal file
Binary file not shown.
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/7ade28accd28c1fb/TRAN.ipch
Normal file
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/7ade28accd28c1fb/TRAN.ipch
Normal file
Binary file not shown.
Binary file not shown.
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/fb38de3c5bc50ce5/UDP.ipch
Normal file
BIN
UDPtext/.vs/UDPtext/v16/ipch/AutoPCH/fb38de3c5bc50ce5/UDP.ipch
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
UDPtext/Debug/UDP.obj
Normal file
BIN
UDPtext/Debug/UDP.obj
Normal file
Binary file not shown.
BIN
UDPtext/Debug/UDPtext.exe
Normal file
BIN
UDPtext/Debug/UDPtext.exe
Normal file
Binary file not shown.
11
UDPtext/Debug/UDPtext.exe.recipe
Normal file
11
UDPtext/Debug/UDPtext.exe.recipe
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\leave1031\Desktop\UDP\UDPtext\Debug\UDPtext.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
BIN
UDPtext/Debug/UDPtext.ilk
Normal file
BIN
UDPtext/Debug/UDPtext.ilk
Normal file
Binary file not shown.
1
UDPtext/Debug/UDPtext.log
Normal file
1
UDPtext/Debug/UDPtext.log
Normal file
@ -0,0 +1 @@
|
||||
UDPtext.vcxproj -> C:\Users\leave1031\Desktop\UDP\UDPtext\Debug\UDPtext.exe
|
BIN
UDPtext/Debug/UDPtext.pdb
Normal file
BIN
UDPtext/Debug/UDPtext.pdb
Normal file
Binary file not shown.
BIN
UDPtext/Debug/UDPtext.tlog/CL.command.1.tlog
Normal file
BIN
UDPtext/Debug/UDPtext.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext/Debug/UDPtext.tlog/CL.read.1.tlog
Normal file
BIN
UDPtext/Debug/UDPtext.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext/Debug/UDPtext.tlog/CL.write.1.tlog
Normal file
BIN
UDPtext/Debug/UDPtext.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
2
UDPtext/Debug/UDPtext.tlog/UDPtext.lastbuildstate
Normal file
2
UDPtext/Debug/UDPtext.tlog/UDPtext.lastbuildstate
Normal file
@ -0,0 +1,2 @@
|
||||
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:TargetPlatformVersion=10.0.19041.0:
|
||||
Debug|Win32|C:\Users\leave1031\Desktop\UDP\UDPtext\|
|
BIN
UDPtext/Debug/UDPtext.tlog/link.command.1.tlog
Normal file
BIN
UDPtext/Debug/UDPtext.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext/Debug/UDPtext.tlog/link.read.1.tlog
Normal file
BIN
UDPtext/Debug/UDPtext.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext/Debug/UDPtext.tlog/link.write.1.tlog
Normal file
BIN
UDPtext/Debug/UDPtext.tlog/link.write.1.tlog
Normal file
Binary file not shown.
2
UDPtext/Debug/UDPtext.vcxproj.FileListAbsolute.txt
Normal file
2
UDPtext/Debug/UDPtext.vcxproj.FileListAbsolute.txt
Normal file
@ -0,0 +1,2 @@
|
||||
C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\Debug\UDPtext.exe
|
||||
C:\Users\leave1031\Desktop\UDP\UDPtext\Debug\UDPtext.exe
|
BIN
UDPtext/Debug/jsoncpp.obj
Normal file
BIN
UDPtext/Debug/jsoncpp.obj
Normal file
Binary file not shown.
BIN
UDPtext/Debug/stdafx.obj
Normal file
BIN
UDPtext/Debug/stdafx.obj
Normal file
Binary file not shown.
BIN
UDPtext/Debug/tran.obj
Normal file
BIN
UDPtext/Debug/tran.obj
Normal file
Binary file not shown.
BIN
UDPtext/Debug/vc142.idb
Normal file
BIN
UDPtext/Debug/vc142.idb
Normal file
Binary file not shown.
BIN
UDPtext/Debug/vc142.pdb
Normal file
BIN
UDPtext/Debug/vc142.pdb
Normal file
Binary file not shown.
77
UDPtext/UDP.cpp
Normal file
77
UDPtext/UDP.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
// UDP.cpp: implementation of the CUDP class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "StdAfx.h"
|
||||
#include "UDP.h"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CUDP::CUDP()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CUDP::~CUDP()
|
||||
{
|
||||
|
||||
}
|
||||
void CUDP::init()
|
||||
{
|
||||
WSAData wsd;
|
||||
if (WSAStartup(MAKEWORD(2,2),&wsd)!=0)
|
||||
{
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
if ((m_SocketSend=socket(AF_INET,SOCK_DGRAM,0))==-1)
|
||||
{
|
||||
perror("NetSocks Failed");
|
||||
exit(0);
|
||||
}
|
||||
int optval=8;
|
||||
if (setsockopt(m_SocketSend,IPPROTO_IP,SO_REUSEADDR,(char*)&optval,sizeof(int))==-1)
|
||||
{
|
||||
perror("setsockopt(IP_TTL)");
|
||||
}
|
||||
if ((m_SocketRecv=socket(AF_INET,SOCK_DGRAM,0))==-1)
|
||||
{
|
||||
perror("NetSocks Failed");
|
||||
exit(0);
|
||||
}
|
||||
if (setsockopt(m_SocketRecv,IPPROTO_IP,SO_REUSEADDR,(char*)&optval,sizeof(int))==-1)
|
||||
{
|
||||
perror("setsockopt(IP_TTL)");
|
||||
}
|
||||
}
|
||||
void CUDP::UDPSend(char buf[],int len,unsigned short PortNo,const char* IP)
|
||||
{
|
||||
SOCKADDR_IN remote;
|
||||
memset((char*)&remote,0,sizeof(SOCKADDR_IN));
|
||||
remote.sin_family=AF_INET;
|
||||
remote.sin_port=htons(PortNo);
|
||||
remote.sin_addr.s_addr=inet_addr(IP);
|
||||
sendto(m_SocketSend,buf,len,0,(SOCKADDR*)&remote,sizeof(SOCKADDR_IN));
|
||||
}
|
||||
void CUDP::UDPRecv(char buf[],int len,unsigned short PortNo,const char* IP)
|
||||
{
|
||||
SOCKADDR_IN localRaddr,remoteSaddr;
|
||||
localRaddr.sin_family=AF_INET;
|
||||
localRaddr.sin_addr.S_un.S_addr=htons(INADDR_ANY);
|
||||
localRaddr.sin_port=htons(PortNo);
|
||||
|
||||
|
||||
remoteSaddr.sin_family=AF_INET;
|
||||
remoteSaddr.sin_addr.S_un.S_addr=inet_addr(IP);
|
||||
remoteSaddr.sin_port=htons(PortNo);
|
||||
|
||||
int socklen=sizeof(SOCKADDR_IN);
|
||||
bind(m_SocketRecv,(SOCKADDR FAR*)&localRaddr,sizeof(SOCKADDR_IN));
|
||||
recvfrom(m_SocketRecv,buf,len,0,(SOCKADDR*)&remoteSaddr,&socklen);
|
||||
}
|
||||
void CUDP::UDPClose()
|
||||
{
|
||||
closesocket(m_SocketRecv);
|
||||
closesocket(m_SocketSend);
|
||||
WSACleanup();
|
||||
}
|
30
UDPtext/UDP.h
Normal file
30
UDPtext/UDP.h
Normal file
@ -0,0 +1,30 @@
|
||||
// UDP.h: interface for the CUDP class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_UDP_H__6E2A5C37_2073_4C02_8FC2_1255471C0157__INCLUDED_)
|
||||
#define AFX_UDP_H__6E2A5C37_2073_4C02_8FC2_1255471C0157__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <stdlib.h>
|
||||
#include <winsock.h>
|
||||
#pragma comment(lib,"ws2_32.lib")
|
||||
class CUDP
|
||||
{
|
||||
public:
|
||||
CUDP();
|
||||
virtual ~CUDP();
|
||||
public:
|
||||
int m_SocketSend;
|
||||
int m_SocketRecv;
|
||||
void init();
|
||||
void UDPSend(char buf[],int len,unsigned short PortNo,const char* IP);
|
||||
void UDPRecv(char buf[],int len,unsigned short PortNo,const char* IP);
|
||||
void UDPClose();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_UDP_H__6E2A5C37_2073_4C02_8FC2_1255471C0157__INCLUDED_)
|
31
UDPtext/UDPtext.sln
Normal file
31
UDPtext/UDPtext.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.33801.447
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDPtext", "UDPtext.vcxproj", "{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x64.Build.0 = Debug|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x64.ActiveCfg = Release|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x64.Build.0 = Release|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8A8131C7-04C3-4C31-BF58-7E235F4636AF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
156
UDPtext/UDPtext.vcxproj
Normal file
156
UDPtext/UDPtext.vcxproj
Normal file
@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{a69270d5-e1e2-4501-8cf0-3381e0dc9aa3}</ProjectGuid>
|
||||
<RootNamespace>UDPtext</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jsoncpp.cpp" />
|
||||
<ClCompile Include="stdafx.cpp" />
|
||||
<ClCompile Include="tran.cpp" />
|
||||
<ClCompile Include="UDP.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="json\json.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="UDP.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
45
UDPtext/UDPtext.vcxproj.filters
Normal file
45
UDPtext/UDPtext.vcxproj.filters
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jsoncpp.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UDP.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tran.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UDP.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="json\json.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
4
UDPtext/UDPtext.vcxproj.user
Normal file
4
UDPtext/UDPtext.vcxproj.user
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
447
UDPtext/json/json-forwards.h
Normal file
447
UDPtext/json/json-forwards.h
Normal file
@ -0,0 +1,447 @@
|
||||
/// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/).
|
||||
/// It is intended to be used with #include "json/json-forwards.h"
|
||||
/// This header provides forward declaration for all JsonCpp types.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: LICENSE
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
tests and demonstration applications, are licensed under the following
|
||||
conditions...
|
||||
|
||||
Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
this software is released into the Public Domain.
|
||||
|
||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
||||
The JsonCpp Authors, and is released under the terms of the MIT License (see below).
|
||||
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
Public Domain/MIT License conditions described here, as they choose.
|
||||
|
||||
The MIT License is about as close to Public Domain as a license can get, and is
|
||||
described in clear, concise terms at:
|
||||
|
||||
http://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
The full text of the MIT License follows:
|
||||
|
||||
========================================================================
|
||||
Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
========================================================================
|
||||
(END LICENSE TEXT)
|
||||
|
||||
The MIT license is compatible with both the GPL and commercial
|
||||
software, affording one all of the rights of Public Domain with the
|
||||
minor nuisance of being required to keep the above copyright notice
|
||||
and license text in the source code. Note also that by accepting the
|
||||
Public Domain "license" you can re-license your copy using whatever
|
||||
license you like.
|
||||
|
||||
*/
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: LICENSE
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||
# define JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||
/// If defined, indicates that the source file is amalgamated
|
||||
/// to prevent private header inclusion.
|
||||
#define JSON_IS_AMALGAMATION
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/version.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
#define JSON_VERSION_H_INCLUDED
|
||||
|
||||
// Note: version must be updated in three places when doing a release. This
|
||||
// annoying process ensures that amalgamate, CMake, and meson all report the
|
||||
// correct version.
|
||||
// 1. /meson.build
|
||||
// 2. /include/json/version.h
|
||||
// 3. /CMakeLists.txt
|
||||
// IMPORTANT: also update the SOVERSION!!
|
||||
|
||||
#define JSONCPP_VERSION_STRING "1.9.5"
|
||||
#define JSONCPP_VERSION_MAJOR 1
|
||||
#define JSONCPP_VERSION_MINOR 9
|
||||
#define JSONCPP_VERSION_PATCH 5
|
||||
#define JSONCPP_VERSION_QUALIFIER
|
||||
#define JSONCPP_VERSION_HEXA \
|
||||
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
||||
(JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY 0
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/version.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/allocator.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_ALLOCATOR_H_INCLUDED
|
||||
#define JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
namespace Json {
|
||||
template <typename T> class SecureAllocator {
|
||||
public:
|
||||
// Type definitions
|
||||
using value_type = T;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* Allocate memory for N items using the standard allocator.
|
||||
*/
|
||||
pointer allocate(size_type n) {
|
||||
// allocate using "global operator new"
|
||||
return static_cast<pointer>(::operator new(n * sizeof(T)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Release memory which was allocated for N items at pointer P.
|
||||
*
|
||||
* The memory block is filled with zeroes before being released.
|
||||
*/
|
||||
void deallocate(pointer p, size_type n) {
|
||||
// memset_s is used because memset may be optimized away by the compiler
|
||||
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
|
||||
// free using "global operator delete"
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an item in-place at pointer P.
|
||||
*/
|
||||
template <typename... Args> void construct(pointer p, Args&&... args) {
|
||||
// construct using "placement new" and "perfect forwarding"
|
||||
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
size_type max_size() const { return size_t(-1) / sizeof(T); }
|
||||
|
||||
pointer address(reference x) const { return std::addressof(x); }
|
||||
|
||||
const_pointer address(const_reference x) const { return std::addressof(x); }
|
||||
|
||||
/**
|
||||
* Destroy an item in-place at pointer P.
|
||||
*/
|
||||
void destroy(pointer p) {
|
||||
// destroy using "explicit destructor"
|
||||
p->~T();
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
SecureAllocator() {}
|
||||
template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
|
||||
template <typename U> struct rebind { using other = SecureAllocator<U>; };
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/allocator.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/config.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
#define JSON_CONFIG_H_INCLUDED
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||
// assertion macros. The default is to use exceptions.
|
||||
#ifndef JSON_USE_EXCEPTION
|
||||
#define JSON_USE_EXCEPTION 1
|
||||
#endif
|
||||
|
||||
// Temporary, tracked for removal with issue #982.
|
||||
#ifndef JSON_USE_NULLREF
|
||||
#define JSON_USE_NULLREF 1
|
||||
#endif
|
||||
|
||||
/// If defined, indicates that the source file is amalgamated
|
||||
/// to prevent private header inclusion.
|
||||
/// Remarks: it is automatically defined in the generated amalgamated header.
|
||||
// #define JSON_IS_AMALGAMATION
|
||||
|
||||
// Export macros for DLL visibility
|
||||
#if defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define JSON_API __attribute__((visibility("default")))
|
||||
#endif // if defined(_MSC_VER)
|
||||
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#endif // ifdef JSON_DLL_BUILD
|
||||
|
||||
#if !defined(JSON_API)
|
||||
#define JSON_API
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
#error \
|
||||
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// As recommended at
|
||||
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
|
||||
extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
|
||||
const char* format, ...);
|
||||
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
|
||||
#else
|
||||
#define jsoncpp_snprintf std::snprintf
|
||||
#endif
|
||||
|
||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||
// integer
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
|
||||
// C++11 should be used directly in JSONCPP.
|
||||
#define JSONCPP_OVERRIDE override
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_extension(attribute_deprecated_with_message)
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#endif
|
||||
#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
#endif // GNUC version
|
||||
#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
|
||||
// MSVC)
|
||||
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#endif // __clang__ || __GNUC__ || _MSC_VER
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
|
||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
#include "allocator.h"
|
||||
#include "version.h"
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
using Int = int;
|
||||
using UInt = unsigned int;
|
||||
#if defined(JSON_NO_INT64)
|
||||
using LargestInt = int;
|
||||
using LargestUInt = unsigned int;
|
||||
#undef JSON_HAS_INT64
|
||||
#else // if defined(JSON_NO_INT64)
|
||||
// For Microsoft Visual use specific types as long long is not supported
|
||||
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||
using Int64 = __int64;
|
||||
using UInt64 = unsigned __int64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
using Int64 = int64_t;
|
||||
using UInt64 = uint64_t;
|
||||
#endif // if defined(_MSC_VER)
|
||||
using LargestInt = Int64;
|
||||
using LargestUInt = UInt64;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
|
||||
template <typename T>
|
||||
using Allocator =
|
||||
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
|
||||
std::allocator<T>>::type;
|
||||
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
|
||||
using IStringStream =
|
||||
std::basic_istringstream<String::value_type, String::traits_type,
|
||||
String::allocator_type>;
|
||||
using OStringStream =
|
||||
std::basic_ostringstream<String::value_type, String::traits_type,
|
||||
String::allocator_type>;
|
||||
using IStream = std::istream;
|
||||
using OStream = std::ostream;
|
||||
} // namespace Json
|
||||
|
||||
// Legacy names (formerly macros).
|
||||
using JSONCPP_STRING = Json::String;
|
||||
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
|
||||
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
|
||||
using JSONCPP_ISTREAM = Json::IStream;
|
||||
using JSONCPP_OSTREAM = Json::OStream;
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/config.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/forwards.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
#define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
// writer.h
|
||||
class StreamWriter;
|
||||
class StreamWriterBuilder;
|
||||
class Writer;
|
||||
class FastWriter;
|
||||
class StyledWriter;
|
||||
class StyledStreamWriter;
|
||||
|
||||
// reader.h
|
||||
class Reader;
|
||||
class CharReader;
|
||||
class CharReaderBuilder;
|
||||
|
||||
// json_features.h
|
||||
class Features;
|
||||
|
||||
// value.h
|
||||
using ArrayIndex = unsigned int;
|
||||
class StaticString;
|
||||
class Path;
|
||||
class PathArgument;
|
||||
class Value;
|
||||
class ValueIteratorBase;
|
||||
class ValueIterator;
|
||||
class ValueConstIterator;
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/forwards.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
2375
UDPtext/json/json.h
Normal file
2375
UDPtext/json/json.h
Normal file
File diff suppressed because it is too large
Load Diff
5342
UDPtext/jsoncpp.cpp
Normal file
5342
UDPtext/jsoncpp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
8
UDPtext/stdafx.cpp
Normal file
8
UDPtext/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// Missile.pch 将作为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
// 引用任何所需的附加头文件,而不是在此文件中引用
|
16
UDPtext/stdafx.h
Normal file
16
UDPtext/stdafx.h
Normal file
@ -0,0 +1,16 @@
|
||||
// stdafx.h : 标准系统包含文件的包含文件,
|
||||
// 或是经常使用但不常更改的
|
||||
// 特定于项目的包含文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的信息
|
||||
// Windows 头文件:
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
// TODO: 在此处引用程序需要的其他头文件
|
8
UDPtext/targetver.h
Normal file
8
UDPtext/targetver.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||
|
||||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||
|
||||
#include <SDKDDKVer.h>
|
150
UDPtext/tran.cpp
Normal file
150
UDPtext/tran.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
#define ceshiip "127.0.0.1"
|
||||
#define RECEIVE 5550 //接收输入信息端口
|
||||
#define SEND 5560 //接收端口
|
||||
#include "UDP.h"
|
||||
#include "json/json.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
CUDP m_UDP;
|
||||
int q,w;
|
||||
char a;
|
||||
double b;
|
||||
HANDLE hThread;
|
||||
HANDLE hThread1;
|
||||
struct SUMMING
|
||||
{
|
||||
unsigned char sum1;
|
||||
unsigned int num1;
|
||||
int num2;
|
||||
}sumning;
|
||||
|
||||
struct json_text
|
||||
{
|
||||
char name;
|
||||
double number;
|
||||
SUMMING truct;
|
||||
|
||||
}on_text;
|
||||
void send_test(json_text* json1)
|
||||
{
|
||||
unsigned char c;
|
||||
Json::Value root;
|
||||
Json::Value truct;
|
||||
root["name"] = Json::Value(&(json1->name));
|
||||
root["number"] = Json::Value(json1->number);
|
||||
truct["sum1"] = Json::Value(reinterpret_cast<char*>(&(json1->truct.sum1)));
|
||||
truct["num1"] = Json::Value(json1->truct.num1);
|
||||
truct["num2"] = Json::Value(json1->truct.num2);
|
||||
root["truct"] = Json::Value(truct);
|
||||
Json::FastWriter syle_writer;
|
||||
std::string s;
|
||||
s = syle_writer.write(root).c_str();
|
||||
char buf[5000];
|
||||
memset(buf, 0, 5000);
|
||||
memcpy(buf, s.c_str(), strlen(s.c_str()));
|
||||
m_UDP.init();
|
||||
m_UDP.UDPSend(buf, 5000, 5560, ceshiip);
|
||||
/*root["struct"]["sum1"] = Json::Value(json1->truct.sum1);
|
||||
root["struct"]["num1"] = Json::Value(json1->truct.num1);
|
||||
root["struct"]["num2"] = Json::Value(json1->truct.num2);*/
|
||||
}
|
||||
|
||||
void* receive_test()
|
||||
{
|
||||
CUDP UDP_ForceData;
|
||||
UDP_ForceData.init();
|
||||
char buf[500];
|
||||
memset(buf, 0, 500);
|
||||
while (1)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
UDP_ForceData.UDPRecv(buf, 500, 5550, ceshiip);
|
||||
Json::Value va;
|
||||
Json::Reader re;
|
||||
re.parse(buf, va);
|
||||
a = *(va["name2"].asCString());
|
||||
b = va["number2"].asDouble();
|
||||
if (b != 0)
|
||||
w = 1;
|
||||
/*on_text.truct.num1 = va["truct"]["num1"].asInt();
|
||||
on_text.truct.num2 = va["truct"]["num2"].asInt();
|
||||
on_text.truct.sum1 = *(va["truct"]["sum1"].asCString());*/
|
||||
CoUninitialize();
|
||||
Sleep(30);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* receive_test_2()
|
||||
{
|
||||
CUDP UDP_ForceData;
|
||||
UDP_ForceData.init();
|
||||
char buf[500];
|
||||
memset(buf, 0, 500);
|
||||
while (1)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
UDP_ForceData.UDPRecv(buf, 500, 5540, ceshiip);
|
||||
Json::Value va;
|
||||
Json::Reader re;
|
||||
re.parse(buf, va);
|
||||
on_text.name = *(va["name"].asCString());
|
||||
on_text.number = va["number"].asDouble();
|
||||
on_text.truct.num1 = va["truct"]["num1"].asInt64();
|
||||
on_text.truct.num2 = va["truct"]["num2"].asInt();
|
||||
on_text.truct.sum1 = *(va["truct"]["sum1"].asCString());
|
||||
if (on_text.number != 3)
|
||||
q = 1;
|
||||
CoUninitialize();
|
||||
Sleep(30);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned a = -15;
|
||||
int c = 1;
|
||||
on_text.name = 'a';
|
||||
on_text.number = 3;
|
||||
on_text.truct.num1 = -15;
|
||||
on_text.truct.num2 = 2;
|
||||
on_text.truct.sum1 = 'b';
|
||||
cout << on_text.truct.sum1 << endl;
|
||||
a = 'a';
|
||||
while (c < 10)
|
||||
{
|
||||
send_test(&on_text);
|
||||
c++;
|
||||
}
|
||||
|
||||
|
||||
if (NULL != (hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)receive_test, NULL, 0, NULL)))
|
||||
{
|
||||
cout << "线程1创建成功!" << endl;
|
||||
}
|
||||
|
||||
if (NULL != (hThread1 = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)receive_test_2, NULL, 0, NULL)))
|
||||
{
|
||||
cout << "线程2创建成功!" << endl;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
if (q == 1 )
|
||||
{
|
||||
cout << "接收到新数据1" << on_text.name << " " << on_text.number << endl;
|
||||
cout << "struct" << on_text.truct.num1 << " " << on_text.truct.num2 << on_text.truct.sum1 << endl;
|
||||
q = 0;
|
||||
}
|
||||
|
||||
if (w == 1)
|
||||
{
|
||||
cout<<"接收到新数据2"<< a << " " << b << endl;
|
||||
w = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
UDPtext_shou/.vs/UDPtext/v16/.suo
Normal file
BIN
UDPtext_shou/.vs/UDPtext/v16/.suo
Normal file
Binary file not shown.
BIN
UDPtext_shou/.vs/UDPtext/v16/Browse.VC.db
Normal file
BIN
UDPtext_shou/.vs/UDPtext/v16/Browse.VC.db
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
UDPtext_shou/Debug/UDP.obj
Normal file
BIN
UDPtext_shou/Debug/UDP.obj
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/UDPtext.exe
Normal file
BIN
UDPtext_shou/Debug/UDPtext.exe
Normal file
Binary file not shown.
11
UDPtext_shou/Debug/UDPtext.exe.recipe
Normal file
11
UDPtext_shou/Debug/UDPtext.exe.recipe
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\Debug\UDPtext.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
BIN
UDPtext_shou/Debug/UDPtext.ilk
Normal file
BIN
UDPtext_shou/Debug/UDPtext.ilk
Normal file
Binary file not shown.
4
UDPtext_shou/Debug/UDPtext.log
Normal file
4
UDPtext_shou/Debug/UDPtext.log
Normal file
@ -0,0 +1,4 @@
|
||||
tran.cpp
|
||||
C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\tran.cpp(30,16): warning C4101: “c”: 未引用的局部变量
|
||||
C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\tran.cpp(94,50): warning C4244: “=”: 从“Json::Value::Int64”转换到“unsigned int”,可能丢失数据
|
||||
UDPtext.vcxproj -> C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\Debug\UDPtext.exe
|
BIN
UDPtext_shou/Debug/UDPtext.pdb
Normal file
BIN
UDPtext_shou/Debug/UDPtext.pdb
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/UDPtext.tlog/CL.command.1.tlog
Normal file
BIN
UDPtext_shou/Debug/UDPtext.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/UDPtext.tlog/CL.read.1.tlog
Normal file
BIN
UDPtext_shou/Debug/UDPtext.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/UDPtext.tlog/CL.write.1.tlog
Normal file
BIN
UDPtext_shou/Debug/UDPtext.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
2
UDPtext_shou/Debug/UDPtext.tlog/UDPtext.lastbuildstate
Normal file
2
UDPtext_shou/Debug/UDPtext.tlog/UDPtext.lastbuildstate
Normal file
@ -0,0 +1,2 @@
|
||||
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:TargetPlatformVersion=10.0.19041.0:
|
||||
Debug|Win32|C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\|
|
BIN
UDPtext_shou/Debug/UDPtext.tlog/link.command.1.tlog
Normal file
BIN
UDPtext_shou/Debug/UDPtext.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/UDPtext.tlog/link.read.1.tlog
Normal file
BIN
UDPtext_shou/Debug/UDPtext.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/UDPtext.tlog/link.write.1.tlog
Normal file
BIN
UDPtext_shou/Debug/UDPtext.tlog/link.write.1.tlog
Normal file
Binary file not shown.
1
UDPtext_shou/Debug/UDPtext.vcxproj.FileListAbsolute.txt
Normal file
1
UDPtext_shou/Debug/UDPtext.vcxproj.FileListAbsolute.txt
Normal file
@ -0,0 +1 @@
|
||||
C:\Users\leave1031\Desktop\UDP(自己)\UDPtext\Debug\UDPtext.exe
|
BIN
UDPtext_shou/Debug/jsoncpp.obj
Normal file
BIN
UDPtext_shou/Debug/jsoncpp.obj
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/stdafx.obj
Normal file
BIN
UDPtext_shou/Debug/stdafx.obj
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/tran.obj
Normal file
BIN
UDPtext_shou/Debug/tran.obj
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/vc142.idb
Normal file
BIN
UDPtext_shou/Debug/vc142.idb
Normal file
Binary file not shown.
BIN
UDPtext_shou/Debug/vc142.pdb
Normal file
BIN
UDPtext_shou/Debug/vc142.pdb
Normal file
Binary file not shown.
77
UDPtext_shou/UDP.cpp
Normal file
77
UDPtext_shou/UDP.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
// UDP.cpp: implementation of the CUDP class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "StdAfx.h"
|
||||
#include "UDP.h"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CUDP::CUDP()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CUDP::~CUDP()
|
||||
{
|
||||
|
||||
}
|
||||
void CUDP::init()
|
||||
{
|
||||
WSAData wsd;
|
||||
if (WSAStartup(MAKEWORD(2,2),&wsd)!=0)
|
||||
{
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
if ((m_SocketSend=socket(AF_INET,SOCK_DGRAM,0))==-1)
|
||||
{
|
||||
perror("NetSocks Failed");
|
||||
exit(0);
|
||||
}
|
||||
int optval=8;
|
||||
if (setsockopt(m_SocketSend,IPPROTO_IP,SO_REUSEADDR,(char*)&optval,sizeof(int))==-1)
|
||||
{
|
||||
perror("setsockopt(IP_TTL)");
|
||||
}
|
||||
if ((m_SocketRecv=socket(AF_INET,SOCK_DGRAM,0))==-1)
|
||||
{
|
||||
perror("NetSocks Failed");
|
||||
exit(0);
|
||||
}
|
||||
if (setsockopt(m_SocketRecv,IPPROTO_IP,SO_REUSEADDR,(char*)&optval,sizeof(int))==-1)
|
||||
{
|
||||
perror("setsockopt(IP_TTL)");
|
||||
}
|
||||
}
|
||||
void CUDP::UDPSend(char buf[],int len,unsigned short PortNo,const char* IP)
|
||||
{
|
||||
SOCKADDR_IN remote;
|
||||
memset((char*)&remote,0,sizeof(SOCKADDR_IN));
|
||||
remote.sin_family=AF_INET;
|
||||
remote.sin_port=htons(PortNo);
|
||||
remote.sin_addr.s_addr=inet_addr(IP);
|
||||
sendto(m_SocketSend,buf,len,0,(SOCKADDR*)&remote,sizeof(SOCKADDR_IN));
|
||||
}
|
||||
void CUDP::UDPRecv(char buf[],int len,unsigned short PortNo,const char* IP)
|
||||
{
|
||||
SOCKADDR_IN localRaddr,remoteSaddr;
|
||||
localRaddr.sin_family=AF_INET;
|
||||
localRaddr.sin_addr.S_un.S_addr=htons(INADDR_ANY);
|
||||
localRaddr.sin_port=htons(PortNo);
|
||||
|
||||
|
||||
remoteSaddr.sin_family=AF_INET;
|
||||
remoteSaddr.sin_addr.S_un.S_addr=inet_addr(IP);
|
||||
remoteSaddr.sin_port=htons(PortNo);
|
||||
|
||||
int socklen=sizeof(SOCKADDR_IN);
|
||||
bind(m_SocketRecv,(SOCKADDR FAR*)&localRaddr,sizeof(SOCKADDR_IN));
|
||||
recvfrom(m_SocketRecv,buf,len,0,(SOCKADDR*)&remoteSaddr,&socklen);
|
||||
}
|
||||
void CUDP::UDPClose()
|
||||
{
|
||||
closesocket(m_SocketRecv);
|
||||
closesocket(m_SocketSend);
|
||||
WSACleanup();
|
||||
}
|
30
UDPtext_shou/UDP.h
Normal file
30
UDPtext_shou/UDP.h
Normal file
@ -0,0 +1,30 @@
|
||||
// UDP.h: interface for the CUDP class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_UDP_H__6E2A5C37_2073_4C02_8FC2_1255471C0157__INCLUDED_)
|
||||
#define AFX_UDP_H__6E2A5C37_2073_4C02_8FC2_1255471C0157__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <stdlib.h>
|
||||
#include <winsock.h>
|
||||
#pragma comment(lib,"ws2_32.lib")
|
||||
class CUDP
|
||||
{
|
||||
public:
|
||||
CUDP();
|
||||
virtual ~CUDP();
|
||||
public:
|
||||
int m_SocketSend;
|
||||
int m_SocketRecv;
|
||||
void init();
|
||||
void UDPSend(char buf[],int len,unsigned short PortNo,const char* IP);
|
||||
void UDPRecv(char buf[],int len,unsigned short PortNo,const char* IP);
|
||||
void UDPClose();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_UDP_H__6E2A5C37_2073_4C02_8FC2_1255471C0157__INCLUDED_)
|
31
UDPtext_shou/UDPtext.sln
Normal file
31
UDPtext_shou/UDPtext.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.33801.447
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDPtext", "UDPtext.vcxproj", "{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x64.Build.0 = Debug|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x64.ActiveCfg = Release|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x64.Build.0 = Release|x64
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A69270D5-E1E2-4501-8CF0-3381E0DC9AA3}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8A8131C7-04C3-4C31-BF58-7E235F4636AF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
156
UDPtext_shou/UDPtext.vcxproj
Normal file
156
UDPtext_shou/UDPtext.vcxproj
Normal file
@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{a69270d5-e1e2-4501-8cf0-3381e0dc9aa3}</ProjectGuid>
|
||||
<RootNamespace>UDPtext</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jsoncpp.cpp" />
|
||||
<ClCompile Include="stdafx.cpp" />
|
||||
<ClCompile Include="tran.cpp" />
|
||||
<ClCompile Include="UDP.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="json\json.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="UDP.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
45
UDPtext_shou/UDPtext.vcxproj.filters
Normal file
45
UDPtext_shou/UDPtext.vcxproj.filters
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jsoncpp.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UDP.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tran.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UDP.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="json\json.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
4
UDPtext_shou/UDPtext.vcxproj.user
Normal file
4
UDPtext_shou/UDPtext.vcxproj.user
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
447
UDPtext_shou/json/json-forwards.h
Normal file
447
UDPtext_shou/json/json-forwards.h
Normal file
@ -0,0 +1,447 @@
|
||||
/// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/).
|
||||
/// It is intended to be used with #include "json/json-forwards.h"
|
||||
/// This header provides forward declaration for all JsonCpp types.
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: LICENSE
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
tests and demonstration applications, are licensed under the following
|
||||
conditions...
|
||||
|
||||
Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
this software is released into the Public Domain.
|
||||
|
||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
||||
The JsonCpp Authors, and is released under the terms of the MIT License (see below).
|
||||
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
Public Domain/MIT License conditions described here, as they choose.
|
||||
|
||||
The MIT License is about as close to Public Domain as a license can get, and is
|
||||
described in clear, concise terms at:
|
||||
|
||||
http://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
The full text of the MIT License follows:
|
||||
|
||||
========================================================================
|
||||
Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
========================================================================
|
||||
(END LICENSE TEXT)
|
||||
|
||||
The MIT license is compatible with both the GPL and commercial
|
||||
software, affording one all of the rights of Public Domain with the
|
||||
minor nuisance of being required to keep the above copyright notice
|
||||
and license text in the source code. Note also that by accepting the
|
||||
Public Domain "license" you can re-license your copy using whatever
|
||||
license you like.
|
||||
|
||||
*/
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: LICENSE
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||
# define JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||
/// If defined, indicates that the source file is amalgamated
|
||||
/// to prevent private header inclusion.
|
||||
#define JSON_IS_AMALGAMATION
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/version.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
#define JSON_VERSION_H_INCLUDED
|
||||
|
||||
// Note: version must be updated in three places when doing a release. This
|
||||
// annoying process ensures that amalgamate, CMake, and meson all report the
|
||||
// correct version.
|
||||
// 1. /meson.build
|
||||
// 2. /include/json/version.h
|
||||
// 3. /CMakeLists.txt
|
||||
// IMPORTANT: also update the SOVERSION!!
|
||||
|
||||
#define JSONCPP_VERSION_STRING "1.9.5"
|
||||
#define JSONCPP_VERSION_MAJOR 1
|
||||
#define JSONCPP_VERSION_MINOR 9
|
||||
#define JSONCPP_VERSION_PATCH 5
|
||||
#define JSONCPP_VERSION_QUALIFIER
|
||||
#define JSONCPP_VERSION_HEXA \
|
||||
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
||||
(JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY 0
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/version.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/allocator.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_ALLOCATOR_H_INCLUDED
|
||||
#define JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
namespace Json {
|
||||
template <typename T> class SecureAllocator {
|
||||
public:
|
||||
// Type definitions
|
||||
using value_type = T;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* Allocate memory for N items using the standard allocator.
|
||||
*/
|
||||
pointer allocate(size_type n) {
|
||||
// allocate using "global operator new"
|
||||
return static_cast<pointer>(::operator new(n * sizeof(T)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Release memory which was allocated for N items at pointer P.
|
||||
*
|
||||
* The memory block is filled with zeroes before being released.
|
||||
*/
|
||||
void deallocate(pointer p, size_type n) {
|
||||
// memset_s is used because memset may be optimized away by the compiler
|
||||
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
|
||||
// free using "global operator delete"
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an item in-place at pointer P.
|
||||
*/
|
||||
template <typename... Args> void construct(pointer p, Args&&... args) {
|
||||
// construct using "placement new" and "perfect forwarding"
|
||||
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
size_type max_size() const { return size_t(-1) / sizeof(T); }
|
||||
|
||||
pointer address(reference x) const { return std::addressof(x); }
|
||||
|
||||
const_pointer address(const_reference x) const { return std::addressof(x); }
|
||||
|
||||
/**
|
||||
* Destroy an item in-place at pointer P.
|
||||
*/
|
||||
void destroy(pointer p) {
|
||||
// destroy using "explicit destructor"
|
||||
p->~T();
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
SecureAllocator() {}
|
||||
template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
|
||||
template <typename U> struct rebind { using other = SecureAllocator<U>; };
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/allocator.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/config.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
#define JSON_CONFIG_H_INCLUDED
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||
// assertion macros. The default is to use exceptions.
|
||||
#ifndef JSON_USE_EXCEPTION
|
||||
#define JSON_USE_EXCEPTION 1
|
||||
#endif
|
||||
|
||||
// Temporary, tracked for removal with issue #982.
|
||||
#ifndef JSON_USE_NULLREF
|
||||
#define JSON_USE_NULLREF 1
|
||||
#endif
|
||||
|
||||
/// If defined, indicates that the source file is amalgamated
|
||||
/// to prevent private header inclusion.
|
||||
/// Remarks: it is automatically defined in the generated amalgamated header.
|
||||
// #define JSON_IS_AMALGAMATION
|
||||
|
||||
// Export macros for DLL visibility
|
||||
#if defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define JSON_API __attribute__((visibility("default")))
|
||||
#endif // if defined(_MSC_VER)
|
||||
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#endif // ifdef JSON_DLL_BUILD
|
||||
|
||||
#if !defined(JSON_API)
|
||||
#define JSON_API
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
#error \
|
||||
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// As recommended at
|
||||
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
|
||||
extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
|
||||
const char* format, ...);
|
||||
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
|
||||
#else
|
||||
#define jsoncpp_snprintf std::snprintf
|
||||
#endif
|
||||
|
||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||
// integer
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
|
||||
// C++11 should be used directly in JSONCPP.
|
||||
#define JSONCPP_OVERRIDE override
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_extension(attribute_deprecated_with_message)
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#endif
|
||||
#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
#endif // GNUC version
|
||||
#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
|
||||
// MSVC)
|
||||
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#endif // __clang__ || __GNUC__ || _MSC_VER
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
|
||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
#include "allocator.h"
|
||||
#include "version.h"
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
using Int = int;
|
||||
using UInt = unsigned int;
|
||||
#if defined(JSON_NO_INT64)
|
||||
using LargestInt = int;
|
||||
using LargestUInt = unsigned int;
|
||||
#undef JSON_HAS_INT64
|
||||
#else // if defined(JSON_NO_INT64)
|
||||
// For Microsoft Visual use specific types as long long is not supported
|
||||
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||
using Int64 = __int64;
|
||||
using UInt64 = unsigned __int64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
using Int64 = int64_t;
|
||||
using UInt64 = uint64_t;
|
||||
#endif // if defined(_MSC_VER)
|
||||
using LargestInt = Int64;
|
||||
using LargestUInt = UInt64;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
|
||||
template <typename T>
|
||||
using Allocator =
|
||||
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
|
||||
std::allocator<T>>::type;
|
||||
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
|
||||
using IStringStream =
|
||||
std::basic_istringstream<String::value_type, String::traits_type,
|
||||
String::allocator_type>;
|
||||
using OStringStream =
|
||||
std::basic_ostringstream<String::value_type, String::traits_type,
|
||||
String::allocator_type>;
|
||||
using IStream = std::istream;
|
||||
using OStream = std::ostream;
|
||||
} // namespace Json
|
||||
|
||||
// Legacy names (formerly macros).
|
||||
using JSONCPP_STRING = Json::String;
|
||||
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
|
||||
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
|
||||
using JSONCPP_ISTREAM = Json::IStream;
|
||||
using JSONCPP_OSTREAM = Json::OStream;
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/config.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// Beginning of content of file: include/json/forwards.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
#define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
// writer.h
|
||||
class StreamWriter;
|
||||
class StreamWriterBuilder;
|
||||
class Writer;
|
||||
class FastWriter;
|
||||
class StyledWriter;
|
||||
class StyledStreamWriter;
|
||||
|
||||
// reader.h
|
||||
class Reader;
|
||||
class CharReader;
|
||||
class CharReaderBuilder;
|
||||
|
||||
// json_features.h
|
||||
class Features;
|
||||
|
||||
// value.h
|
||||
using ArrayIndex = unsigned int;
|
||||
class StaticString;
|
||||
class Path;
|
||||
class PathArgument;
|
||||
class Value;
|
||||
class ValueIteratorBase;
|
||||
class ValueIterator;
|
||||
class ValueConstIterator;
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
// End of content of file: include/json/forwards.h
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
2375
UDPtext_shou/json/json.h
Normal file
2375
UDPtext_shou/json/json.h
Normal file
File diff suppressed because it is too large
Load Diff
5342
UDPtext_shou/jsoncpp.cpp
Normal file
5342
UDPtext_shou/jsoncpp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
8
UDPtext_shou/stdafx.cpp
Normal file
8
UDPtext_shou/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// Missile.pch 将作为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
// 引用任何所需的附加头文件,而不是在此文件中引用
|
16
UDPtext_shou/stdafx.h
Normal file
16
UDPtext_shou/stdafx.h
Normal file
@ -0,0 +1,16 @@
|
||||
// stdafx.h : 标准系统包含文件的包含文件,
|
||||
// 或是经常使用但不常更改的
|
||||
// 特定于项目的包含文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的信息
|
||||
// Windows 头文件:
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
// TODO: 在此处引用程序需要的其他头文件
|
8
UDPtext_shou/targetver.h
Normal file
8
UDPtext_shou/targetver.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||
|
||||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||
|
||||
#include <SDKDDKVer.h>
|
150
UDPtext_shou/tran.cpp
Normal file
150
UDPtext_shou/tran.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
#define ceshiip "127.0.0.1"
|
||||
#define RECEIVE 5550 //接收输入信息端口
|
||||
#define SEND 5560 //接收端口
|
||||
#include "UDP.h"
|
||||
#include "json/json.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
CUDP m_UDP;
|
||||
int q,w;
|
||||
char a;
|
||||
double b;
|
||||
HANDLE hThread;
|
||||
HANDLE hThread1;
|
||||
struct SUMMING
|
||||
{
|
||||
unsigned char sum1;
|
||||
unsigned int num1;
|
||||
int num2;
|
||||
}sumning;
|
||||
|
||||
struct json_text
|
||||
{
|
||||
char name;
|
||||
double number;
|
||||
SUMMING truct;
|
||||
|
||||
}on_text;
|
||||
void send_test(json_text* json1)
|
||||
{
|
||||
unsigned char c;
|
||||
Json::Value root;
|
||||
Json::Value truct;
|
||||
root["name"] = Json::Value(&(json1->name));
|
||||
root["number"] = Json::Value(json1->number);
|
||||
truct["sum1"] = Json::Value(reinterpret_cast<char*>(&(json1->truct.sum1)));
|
||||
truct["num1"] = Json::Value(json1->truct.num1);
|
||||
truct["num2"] = Json::Value(json1->truct.num2);
|
||||
root["truct"] = Json::Value(truct);
|
||||
Json::FastWriter syle_writer;
|
||||
std::string s;
|
||||
s = syle_writer.write(root).c_str();
|
||||
char buf[5000];
|
||||
memset(buf, 0, 5000);
|
||||
memcpy(buf, s.c_str(), strlen(s.c_str()));
|
||||
m_UDP.init();
|
||||
m_UDP.UDPSend(buf, 5000, 5560, ceshiip);
|
||||
/*root["struct"]["sum1"] = Json::Value(json1->truct.sum1);
|
||||
root["struct"]["num1"] = Json::Value(json1->truct.num1);
|
||||
root["struct"]["num2"] = Json::Value(json1->truct.num2);*/
|
||||
}
|
||||
|
||||
void* receive_test()
|
||||
{
|
||||
CUDP UDP_ForceData;
|
||||
UDP_ForceData.init();
|
||||
char buf[500];
|
||||
memset(buf, 0, 500);
|
||||
while (1)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
UDP_ForceData.UDPRecv(buf, 500, 5550, ceshiip);
|
||||
Json::Value va;
|
||||
Json::Reader re;
|
||||
re.parse(buf, va);
|
||||
a = *(va["name2"].asCString());
|
||||
b = va["number2"].asDouble();
|
||||
if (b != 0)
|
||||
w = 1;
|
||||
/*on_text.truct.num1 = va["truct"]["num1"].asInt();
|
||||
on_text.truct.num2 = va["truct"]["num2"].asInt();
|
||||
on_text.truct.sum1 = *(va["truct"]["sum1"].asCString());*/
|
||||
CoUninitialize();
|
||||
Sleep(30);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* receive_test_2()
|
||||
{
|
||||
CUDP UDP_ForceData;
|
||||
UDP_ForceData.init();
|
||||
char buf[500];
|
||||
memset(buf, 0, 500);
|
||||
while (1)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
UDP_ForceData.UDPRecv(buf, 500, 5540, ceshiip);
|
||||
Json::Value va;
|
||||
Json::Reader re;
|
||||
re.parse(buf, va);
|
||||
on_text.name = *(va["name"].asCString());
|
||||
on_text.number = va["number"].asDouble();
|
||||
on_text.truct.num1 = va["truct"]["num1"].asInt64();
|
||||
on_text.truct.num2 = va["truct"]["num2"].asInt();
|
||||
on_text.truct.sum1 = *(va["truct"]["sum1"].asCString());
|
||||
if (on_text.number != 3)
|
||||
q = 1;
|
||||
CoUninitialize();
|
||||
Sleep(30);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned a = -15;
|
||||
int c = 1;
|
||||
on_text.name = 'a';
|
||||
on_text.number = 3;
|
||||
on_text.truct.num1 = -15;
|
||||
on_text.truct.num2 = 2;
|
||||
on_text.truct.sum1 = 'b';
|
||||
cout << on_text.truct.sum1 << endl;
|
||||
a = 'a';
|
||||
while (c < 10)
|
||||
{
|
||||
send_test(&on_text);
|
||||
c++;
|
||||
}
|
||||
|
||||
|
||||
if (NULL != (hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)receive_test, NULL, 0, NULL)))
|
||||
{
|
||||
cout << "线程1创建成功!" << endl;
|
||||
}
|
||||
|
||||
if (NULL != (hThread1 = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)receive_test_2, NULL, 0, NULL)))
|
||||
{
|
||||
cout << "线程2创建成功!" << endl;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
if (q == 1 )
|
||||
{
|
||||
cout << "接收到新数据1" << on_text.name << " " << on_text.number << endl;
|
||||
cout << "struct" << on_text.truct.num1 << " " << on_text.truct.num2 << on_text.truct.sum1 << endl;
|
||||
q = 0;
|
||||
}
|
||||
|
||||
if (w == 1)
|
||||
{
|
||||
cout<<"接收到新数据2"<< a << " " << b << endl;
|
||||
w = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user