note: wip commit, in-progress

added tcp/udp structs
added serialisation
fixed vcxproj
updated ping-pong
This commit is contained in:
Jak Barnes 2019-02-20 01:12:33 +00:00
parent 451947b440
commit 4c9057cec2
14 changed files with 1207 additions and 264 deletions

View File

@ -24,6 +24,7 @@
int main() int main()
{ {
// Setup // Setup
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
@ -40,7 +41,8 @@ int main()
AddressInformation serveraddr; AddressInformation serveraddr;
Socket server; Socket server;
server.blocking = false; server.blocking = false;
GetAddressInformation(&serveraddr, "localhost", "3490", SOCKET_TCP, PROTOCOL_TCP); ResolveHost(&serveraddr, "localhost", "3490", SOCKET_TCP);
CreateSocket(&server, serveraddr); CreateSocket(&server, serveraddr);
BindSocket(server, serveraddr); BindSocket(server, serveraddr);
ListenSocket(server); ListenSocket(server);
@ -49,7 +51,7 @@ int main()
AddressInformation clientaddr; AddressInformation clientaddr;
Socket client; Socket client;
client.blocking = false; client.blocking = false;
GetAddressInformation(&clientaddr, "localhost", "3490", SOCKET_TCP, PROTOCOL_TCP); ResolveHost(&clientaddr, "localhost", "3490", SOCKET_TCP);
CreateSocket(&client, clientaddr); CreateSocket(&client, clientaddr);
ConnectSocket(client, clientaddr); ConnectSocket(client, clientaddr);

View File

@ -31,11 +31,15 @@ int main()
screenWidth, screenHeight, "raylib [network] example - ping pong"); screenWidth, screenHeight, "raylib [network] example - ping pong");
SetTargetFPS(60); SetTargetFPS(60);
SetTraceLogLevel(LOG_DEBUG);
// Networking // Networking
InitNetwork(); InitNetwork();
ResolveHost("www.google.com");
ResolveIP("2001:4860:4860::8888"); AddressInformation addr;
ResolveIP("8.8.8.8"); ResolveHost(&addr, "www.google.com", NULL, SOCKET_TCP);
ResolveIP("8.8.8.8", NULL);
ResolveIP("2001:4860:4860::8888", "80");
// Main game loop // Main game loop
while (!WindowShouldClose()) while (!WindowShouldClose())

View File

@ -0,0 +1,74 @@
/*******************************************************************************************
*
* raylib [network] example - Resolve host
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This example has been created using raylib 2.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
*for details)
*
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#include <string.h>
int main()
{
// Setup
int screenWidth = 800;
int screenHeight = 450;
InitWindow(
screenWidth, screenHeight, "raylib [network] example - ping pong");
SetTargetFPS(60);
SetTraceLogLevel(LOG_DEBUG);
// Networking
InitNetwork();
unsigned char buf[1024];
unsigned char magic;
int monkeycount;
long altitude;
double absurdityfactor;
char* s = "Great unmitigated Zot! You've found the Runestaff!";
char s2[96];
unsigned int packetsize, ps2;
packetsize = PackData(buf, "CHhlsd", 'B', 0, 37, -5, s, -3490.5);
packi16(buf + 1, packetsize); // store packet size in packet for kicks
printf("packet is %u bytes\n", packetsize);
UnpackData(buf, "CHhl96sd", &magic, &ps2, &monkeycount, &altitude, s2, &absurdityfactor);
printf("'%c' %hhu %u %ld \"%s\" %f\n", magic, ps2, monkeycount, altitude, s2, absurdityfactor);
// Main game loop
while (!WindowShouldClose())
{
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
}

View File

@ -30,7 +30,7 @@
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{80AE5E50-FAC7-434F-A898-2878568E7D79}</ProjectGuid> <ProjectGuid>{80AE5E50-FAC7-434F-A898-2878568E7D79}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>networkpingpong</RootNamespace> <RootNamespace>network_chat_client</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<ProjectName>network_chat_client</ProjectName> <ProjectName>network_chat_client</ProjectName>
</PropertyGroup> </PropertyGroup>

View File

@ -18,21 +18,21 @@
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\examples\network\network_resolve_host.c" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\raylib\raylib.vcxproj"> <ProjectReference Include="..\raylib\raylib.vcxproj">
<Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project> <Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\examples\network\network_chat_server.c" />
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}</ProjectGuid> <ProjectGuid>{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>networkpingpong</RootNamespace> <RootNamespace>network_chat_server</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<ProjectName>network_stream_client</ProjectName> <ProjectName>network_chat_server</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

View File

@ -30,7 +30,7 @@
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{56EB485C-00A9-459E-B758-2E86316EB7FD}</ProjectGuid> <ProjectGuid>{56EB485C-00A9-459E-B758-2E86316EB7FD}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>networkpingpong</RootNamespace> <RootNamespace>network_ping_pong</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

View File

@ -18,19 +18,19 @@
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\examples\network\network_resolve_host.c" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\raylib\raylib.vcxproj"> <ProjectReference Include="..\raylib\raylib.vcxproj">
<Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project> <Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\examples\network\network_resolve_host.c" />
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{A16D19CB-6AF4-4D17-8318-EABD8805247C}</ProjectGuid> <ProjectGuid>{A16D19CB-6AF4-4D17-8318-EABD8805247C}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>networkpingpong</RootNamespace> <RootNamespace>network_resolve_host</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<ProjectName>network_resolve_host</ProjectName> <ProjectName>network_resolve_host</ProjectName>
</PropertyGroup> </PropertyGroup>

View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" 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>
<ItemGroup>
<ClCompile Include="..\..\..\examples\network\network_serialisation.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\raylib\raylib.vcxproj">
<Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{46B18968-56BC-4FB1-A7C0-FA418E095AFD}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>network_serialisation</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<ProjectName>network_serialisation</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</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>
<OutDir>$(ProjectDir)$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)$(ProjectName)\$(Configuration)\temp</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>
</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -9,15 +9,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_basic_window_cpp", "ex
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_ping_pong", "examples\network_ping_pong.vcxproj", "{56EB485C-00A9-459E-B758-2E86316EB7FD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_basic_window", "examples\core_basic_window.vcxproj", "{0981CA98-E4A5-4DF1-987F-A41D09131EFC}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_basic_window", "examples\core_basic_window.vcxproj", "{0981CA98-E4A5-4DF1-987F-A41D09131EFC}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_resolve_host", "examples\network_interfaces.vcxproj", "{A16D19CB-6AF4-4D17-8318-EABD8805247C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_chat_client", "examples\network_chat_client.vcxproj", "{80AE5E50-FAC7-434F-A898-2878568E7D79}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_chat_client", "examples\network_chat_client.vcxproj", "{80AE5E50-FAC7-434F-A898-2878568E7D79}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_stream_client", "examples\network_chat_server.vcxproj", "{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_chat_server", "examples\network_chat_server.vcxproj", "{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_ping_pong", "examples\network_ping_pong.vcxproj", "{56EB485C-00A9-459E-B758-2E86316EB7FD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_serialisation", "examples\network_resolve_host.vcxproj", "{A16D19CB-6AF4-4D17-8318-EABD8805247C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network_resolve_host", "examples\network_serialisation.vcxproj", "{46B18968-56BC-4FB1-A7C0-FA418E095AFD}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -55,22 +57,6 @@ Global
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x64.ActiveCfg = Release|Win32 {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x64.ActiveCfg = Release|Win32
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.ActiveCfg = Release|Win32 {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.ActiveCfg = Release|Win32
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.Build.0 = Release|Win32 {B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.Build.0 = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x64.ActiveCfg = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x64.Build.0 = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x86.ActiveCfg = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x86.Build.0 = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x64.ActiveCfg = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x64.Build.0 = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x86.ActiveCfg = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x86.Build.0 = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x64.ActiveCfg = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x64.Build.0 = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x86.ActiveCfg = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x86.Build.0 = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x64.ActiveCfg = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x64.Build.0 = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x86.ActiveCfg = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x86.Build.0 = Release|Win32
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x64.ActiveCfg = Debug.DLL|Win32 {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x64.ActiveCfg = Debug.DLL|Win32
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
@ -83,22 +69,6 @@ Global
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x64.ActiveCfg = Release|Win32 {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x64.ActiveCfg = Release|Win32
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.ActiveCfg = Release|Win32 {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.ActiveCfg = Release|Win32
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.Build.0 = Release|Win32 {0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.Build.0 = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x64.ActiveCfg = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x64.Build.0 = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x86.ActiveCfg = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x86.Build.0 = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x64.ActiveCfg = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x64.Build.0 = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x86.ActiveCfg = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x86.Build.0 = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x64.ActiveCfg = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x64.Build.0 = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x86.ActiveCfg = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x86.Build.0 = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x64.ActiveCfg = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x64.Build.0 = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x86.ActiveCfg = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x86.Build.0 = Release|Win32
{80AE5E50-FAC7-434F-A898-2878568E7D79}.Debug.DLL|x64.ActiveCfg = Debug|x64 {80AE5E50-FAC7-434F-A898-2878568E7D79}.Debug.DLL|x64.ActiveCfg = Debug|x64
{80AE5E50-FAC7-434F-A898-2878568E7D79}.Debug.DLL|x64.Build.0 = Debug|x64 {80AE5E50-FAC7-434F-A898-2878568E7D79}.Debug.DLL|x64.Build.0 = Debug|x64
{80AE5E50-FAC7-434F-A898-2878568E7D79}.Debug.DLL|x86.ActiveCfg = Debug|Win32 {80AE5E50-FAC7-434F-A898-2878568E7D79}.Debug.DLL|x86.ActiveCfg = Debug|Win32
@ -131,17 +101,66 @@ Global
{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}.Release|x64.Build.0 = Release|x64 {BC49AAF0-E8C2-4F94-A60A-C56993023C6D}.Release|x64.Build.0 = Release|x64
{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}.Release|x86.ActiveCfg = Release|Win32 {BC49AAF0-E8C2-4F94-A60A-C56993023C6D}.Release|x86.ActiveCfg = Release|Win32
{BC49AAF0-E8C2-4F94-A60A-C56993023C6D}.Release|x86.Build.0 = Release|Win32 {BC49AAF0-E8C2-4F94-A60A-C56993023C6D}.Release|x86.Build.0 = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x64.ActiveCfg = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x64.Build.0 = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x86.ActiveCfg = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug.DLL|x86.Build.0 = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x64.ActiveCfg = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x64.Build.0 = Debug|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x86.ActiveCfg = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Debug|x86.Build.0 = Debug|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x64.ActiveCfg = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x64.Build.0 = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x86.ActiveCfg = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release.DLL|x86.Build.0 = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x64.ActiveCfg = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x64.Build.0 = Release|x64
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x86.ActiveCfg = Release|Win32
{56EB485C-00A9-459E-B758-2E86316EB7FD}.Release|x86.Build.0 = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x64.ActiveCfg = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x64.Build.0 = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x86.ActiveCfg = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug.DLL|x86.Build.0 = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x64.ActiveCfg = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x64.Build.0 = Debug|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x86.ActiveCfg = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Debug|x86.Build.0 = Debug|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x64.ActiveCfg = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x64.Build.0 = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x86.ActiveCfg = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release.DLL|x86.Build.0 = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x64.ActiveCfg = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x64.Build.0 = Release|x64
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x86.ActiveCfg = Release|Win32
{A16D19CB-6AF4-4D17-8318-EABD8805247C}.Release|x86.Build.0 = Release|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug.DLL|x64.ActiveCfg = Debug|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug.DLL|x64.Build.0 = Debug|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug.DLL|x86.ActiveCfg = Debug|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug.DLL|x86.Build.0 = Debug|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug|x64.ActiveCfg = Debug|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug|x64.Build.0 = Debug|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug|x86.ActiveCfg = Debug|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Debug|x86.Build.0 = Debug|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release.DLL|x64.ActiveCfg = Release|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release.DLL|x64.Build.0 = Release|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release.DLL|x86.ActiveCfg = Release|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release.DLL|x86.Build.0 = Release|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release|x64.ActiveCfg = Release|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release|x64.Build.0 = Release|x64
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release|x86.ActiveCfg = Release|Win32
{46B18968-56BC-4FB1-A7C0-FA418E095AFD}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{B655E850-3322-42F7-941D-6AC18FD66CA1} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} {B655E850-3322-42F7-941D-6AC18FD66CA1} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{56EB485C-00A9-459E-B758-2E86316EB7FD} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{0981CA98-E4A5-4DF1-987F-A41D09131EFC} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} {0981CA98-E4A5-4DF1-987F-A41D09131EFC} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{A16D19CB-6AF4-4D17-8318-EABD8805247C} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{80AE5E50-FAC7-434F-A898-2878568E7D79} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} {80AE5E50-FAC7-434F-A898-2878568E7D79} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{BC49AAF0-E8C2-4F94-A60A-C56993023C6D} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} {BC49AAF0-E8C2-4F94-A60A-C56993023C6D} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{56EB485C-00A9-459E-B758-2E86316EB7FD} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{A16D19CB-6AF4-4D17-8318-EABD8805247C} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
{46B18968-56BC-4FB1-A7C0-FA418E095AFD} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29} SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}

View File

@ -185,6 +185,7 @@
<ClInclude Include="..\..\..\src\raylib.h" /> <ClInclude Include="..\..\..\src\raylib.h" />
<ClInclude Include="..\..\..\src\raymath.h" /> <ClInclude Include="..\..\..\src\raymath.h" />
<ClInclude Include="..\..\..\src\rlgl.h" /> <ClInclude Include="..\..\..\src\rlgl.h" />
<ClInclude Include="..\..\..\src\rpack.h" />
<ClInclude Include="..\..\..\src\sysnet.h" /> <ClInclude Include="..\..\..\src\sysnet.h" />
<ClInclude Include="..\..\..\src\utils.h" /> <ClInclude Include="..\..\..\src\utils.h" />
</ItemGroup> </ItemGroup>

View File

@ -100,6 +100,10 @@
// Network limits // Network limits
#define MAX_SOCKET_SET_SIZE 32 #define MAX_SOCKET_SET_SIZE 32
#define MAX_SOCKET_QUEUE_SIZE 16 #define MAX_SOCKET_QUEUE_SIZE 16
#define MAX_HOST_NAME_SIZE NI_MAXHOST
#define MAX_SERV_NAME_SIZE NI_MAXSERV
#define MAX_IPV4_NAME_SIZE INET6_ADDRSTRLEN
#define MAX_IPV6_NAME_SIZE INET_ADDRSTRLEN
// NOTE: MSC C++ compiler does not support compound literals (C99 feature) // NOTE: MSC C++ compiler does not support compound literals (C99 feature)
// Plain structures in C++ (without constructors) can be initialized from { } initializers. // Plain structures in C++ (without constructors) can be initialized from { } initializers.
@ -425,13 +429,40 @@ typedef struct VrStereoConfig {
int eyeViewportLeft[4]; // VR stereo rendering left eye viewport [x, y, w, h] int eyeViewportLeft[4]; // VR stereo rendering left eye viewport [x, y, w, h]
} VrStereoConfig; } VrStereoConfig;
typedef struct IPAddress
{
int family;
union {
struct
{
unsigned int host; /* 32-bit IPv4 host address */
unsigned short port; /* 16-bit protocol port */
} ip4;
struct
{
unsigned char host[16]; /* 128-bit IPv6 host address */
} ip6;
} data;
} IPAddress;
typedef struct IPv4address
{
unsigned int host; /* 32-bit IPv4 host address */
unsigned short port; /* 16-bit protocol port */
} IPv4address;
typedef struct IPv6address
{
unsigned char bytes[16]; /* 128-bit IPv6 host address */
} IPv6address;
typedef struct AddressInformation typedef struct AddressInformation
{ {
int flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST int flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST
int family; // PF_xxx int family; // PF_xxx
int socktype; // SOCK_xxx int socktype; // SOCK_xxx
int protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 int protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6
size_t addrlen; // Length of ai_addr unsigned int addrlen; // Length of ai_addr
char * canonname; // Canonical name for nodename char * canonname; // Canonical name for nodename
struct SocketAddress *sockaddr; // Binary address struct SocketAddress *sockaddr; // Binary address
struct AddressInformation *next; // Next structure in linked list struct AddressInformation *next; // Next structure in linked list
@ -446,34 +477,73 @@ typedef struct SocketAddress
// Socket // Socket
typedef struct Socket typedef struct Socket
{ {
int ready;
SocketHandle handle; SocketHandle handle;
IPv4address address;
bool blocking; bool blocking;
// int ready;
// SocketHandle handle;
// IPAddress address;
// bool blocking;
} Socket; } Socket;
//typedef struct UDPSocket
//{
// int ready;
// SocketHandle handle;
// IPAddress address;
// bool blocking;
//} UDPSocket;
//
//typedef struct UDPPacket
//{
// int channel; /* The src/dst channel of the packet */
// char * data; /* The packet data */
// int len; /* The length of the packet data */
// int maxlen; /* The size of the data buffer */
// int status; /* packet status after sending */
// IPAddress address; /* The source/dest address of an incoming/outgoing packet */
//} UDPPacket;
//
//typedef struct TCPSocket
//{
// int ready;
// SocketHandle channel;
// IPAddress remoteAddress;
// IPAddress localAddress;
// bool isServer;
// bool blocking;
//} TCPSocket;
//
//typedef struct TCPPacket
//{
// const void *data; /* The packet data */
// int len; /* The length of the packet data */
// int maxlen; /* The size of the data buffer */
//} TCPPacket;
typedef struct SocketSet typedef struct SocketSet
{ {
Socket sockets[MAX_SOCKET_SET_SIZE]; Socket *sockets[MAX_SOCKET_SET_SIZE];
} SocketSet; } SocketSet;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Enumerators Definition // Enumerators Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef enum typedef enum
{ {
SOCKET_ANY = 0, // ACCEPT_ALL
SOCKET_TCP = 1, // SOCK_STREAM SOCKET_TCP = 1, // SOCK_STREAM
SOCKET_UDP = 2 // SOCK_DGRAM SOCKET_UDP = 2 // SOCK_DGRAM
} SocketType; } SocketType;
typedef enum typedef enum
{ {
PROTOCOL_ANY = 0, // ACCEPT_ALL FAMILY_IPv4 = 1,
PROTOCOL_TCP = 6, // IPPROTO_TCP FAMILY_IPv6 = 2
PROTOCOL_UDP = 17 // IPPROTO_UDP } AddressFamily;
} ProtocolType;
// System config flags // System config flags
// NOTE: Used for bit masks // NOTE: Used for bit masks
@ -1431,28 +1501,39 @@ RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pit
// Network functions // Network functions
RLAPI bool InitNetwork(void); RLAPI bool InitNetwork(void);
RLAPI void CloseNetwork(void); RLAPI void CloseNetwork(void);
RLAPI void ResolveHost(AddressInformation *outaddr, const char *address, const char *port, SocketType socketType);
RLAPI void GetAddressInformation(AddressInformation* outaddr, const char* address, const char* port, int socketType, int protocolType); RLAPI char *ResolveIP(const char *host, const char *port);
RLAPI bool IsIPv4Address(const char *host);
RLAPI bool IsIPv6Address(const char *host);
RLAPI int GetIPFamily(const char *host);
RLAPI void GetLocalAddresses();
RLAPI bool CreateSocket(Socket *socket, AddressInformation outaddr); RLAPI bool CreateSocket(Socket *socket, AddressInformation outaddr);
RLAPI bool BindSocket(Socket socket, const AddressInformation addr); RLAPI bool BindSocket(Socket socket, const AddressInformation addr);
RLAPI bool ConnectSocket(Socket socket, const AddressInformation addr); RLAPI bool ConnectSocket(Socket socket, const AddressInformation addr);
RLAPI bool ListenSocket(Socket socket); RLAPI bool ListenSocket(Socket socket);
RLAPI void CloseSocket(Socket *socket); RLAPI void CloseSocket(Socket *socket);
RLAPI void AcceptSocket(Socket listenSock, Socket *newSock); RLAPI void AcceptSocket(Socket listenSock, Socket *newSock);
RLAPI char *SocketAddressToString(SocketAddress *sockaddr, char buffer[]); RLAPI char *SocketAddressToString(SocketAddress *sockaddr, char buffer[]);
RLAPI void PrintSocket(SocketAddress *addr, const int family, const int socktype, const int protocol); RLAPI void PrintSocket(SocketAddress *addr, const int family, const int socktype, const int protocol);
RLAPI void ResolveHost(const char* hostname);
RLAPI void ResolveIP(const char* ip);
RLAPI unsigned int PackData(unsigned char *buf, char *format, ...);
RLAPI void UnpackData(unsigned char *buf, char *format, ...);
RLAPI unsigned short HostToNetworkShort(unsigned short value); // 2 bytes - 0 to 65,535
RLAPI unsigned long HostToNetworkLong(unsigned long value); // 4 bytes - 0 to 4,294,967,295
RLAPI unsigned int HostToNetworkFloat(float value); // 4 bytes - 1.2E-38 to 3.4E+38
RLAPI unsigned long long HostToNetworkDouble(double value); // 8 bytes - 2.3E-308 to 1.7E+308
RLAPI unsigned long long HostToNetworkLongLong(unsigned long long value); // 8 bytes - 0 to 1.8446744073709551615 × 10^19
RLAPI unsigned short NetworkToHostShort(unsigned short value); // 2 byte - 0 to 65,535
RLAPI unsigned long NetworkToHostLong(unsigned long value); // 4 byte - 0 to 4,294,967,295
RLAPI float NetworkToHostFloat(unsigned int value); // 4 byte - 1.2E-38 to 3.4E+38
RLAPI double NetworkToHostDouble(unsigned long long value); // 8 byte - 2.3E-308 to 1.7E+308
RLAPI unsigned long long NetworkToHostLongLong(unsigned long long value); // 8 byte - 0 to 1.8446744073709551615 × 10^19
RLAPI void CreateListenServer(Socket *socket, const char *address, const int port, SocketType socketType); RLAPI void CreateListenServer(Socket *socket, const char *address, const int port, SocketType socketType);
RLAPI void CreateClient(Socket *socket, const char *address, const char *port, SocketType socketType); RLAPI void CreateClient(Socket *socket, const char *address, const char *port, SocketType socketType);
RLAPI int Send(SocketHandle sockfd, const char *data, int len); RLAPI int Send(SocketHandle sockfd, const char *data, int len);
RLAPI int Receive(SocketHandle sockfd, const char *data, int len); RLAPI int Receive(SocketHandle sockfd, const char *data, int len);
RLAPI void ResetSocket(Socket *socket); RLAPI void ResetSocket(Socket *socket);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif

View File

@ -48,9 +48,7 @@
#include "raylib.h" #include "raylib.h"
#include "sysnet.h" #include "sysnet.h"
#include "rpack.h"
#include <errno.h>
#include <stdlib.h>
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module defines // Module defines
@ -92,8 +90,87 @@ void CloseNetwork()
#endif #endif
} }
// Resolve the hostname
char* ResolveIP(const char* ip, const char* port)
{
// Variables
char host[MAX_HOST_NAME_SIZE];
char service[NI_MAXSERV];
int status; // Status value to return (0) is success
struct addrinfo hints; // Address flags (IPV4, IPV6, UDP?)
struct addrinfo* results; // A pointer to the resulting address list
// Zero out the host buffer
memset(&host, '\0', sizeof(host));
memset(&service, '\0', sizeof(service));
// Set the hints
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // Either IPv4 or IPv6 (AF_INET, AF_INET6)
hints.ai_socktype = SOCKET_TCP; // TCP (SOCK_STREAM), UDP (SOCK_DGRAM)
hints.ai_protocol = 0; // Automatically select correct protocol (IPPROTO_TCP), (IPPROTO_UDP)
// Populate address information
status = getaddrinfo(ip, // e.g. "www.example.com" or IP
port, // e.g. "http" or port number
&hints, // e.g. SOCK_STREAM/SOCK_DGRAM
&results // The struct to populate
);
// Did we succeed?
if (status != 0)
{
TraceLog(LOG_WARNING, "Failed to get resolve host %s:%s: %ls", ip, port, gai_strerror(errno));
}
else
{
TraceLog(LOG_DEBUG, "Resolving... %s::%s", ip, port);
}
// Attempt to resolve network byte order ip to hostname
switch (results->ai_family)
{
case AF_INET:
status = getnameinfo(&*((struct sockaddr_in*) results->ai_addr),
sizeof(*((struct sockaddr_in*) results->ai_addr)),
host,
sizeof(host),
NULL,
NULL,
0);
break;
case AF_INET6:
status = getnameinfo(&*((struct sockaddr_in6*) results->ai_addr),
sizeof(*((struct sockaddr_in6*) results->ai_addr)),
host,
sizeof(host),
NULL,
NULL,
0);
break;
default:
break;
}
// Did we succeed?
if (status != 0)
{
TraceLog(LOG_WARNING, "Failed to resolve ip %s: %ls", ip, gai_strerror(errno));
}
else
{
TraceLog(LOG_INFO, "Successfully resolved %s::%s to %s", ip, port, host);
}
// Free the pointer to the data returned by addrinfo
freeaddrinfo(results);
// Return the resulting hostname
return host;
}
// Get address information // Get address information
void GetAddressInformation(AddressInformation* outaddr, const char* address, const char* port, int socketType, int protocolType) void ResolveHost(AddressInformation* outaddr, const char* address, const char* port, SocketType socketType)
{ {
// Variables // Variables
int status; // Status value to return (0) is success int status; // Status value to return (0) is success
@ -103,8 +180,14 @@ void GetAddressInformation(AddressInformation* outaddr, const char* address, con
// Set the hints // Set the hints
memset(&hints, 0, sizeof hints); memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // Either IPv4 or IPv6 (AF_INET, AF_INET6) hints.ai_family = AF_UNSPEC; // Either IPv4 or IPv6 (AF_INET, AF_INET6)
hints.ai_socktype = socketType; // TCP (SOCK_STREAM), UDP (SOCK_DGRAM) hints.ai_socktype = socketType == SOCKET_TCP ? SOCK_STREAM : SOCK_DGRAM; // TCP (SOCK_STREAM), UDP (SOCK_DGRAM)
hints.ai_protocol = protocolType; // TCP (IPPROTO_TCP), UDP (IPPROTO_UDP) hints.ai_protocol = 0; // Automatically select correct protocol (IPPROTO_TCP), (IPPROTO_UDP)
// When the address is NULL, populate the IP for me
if (address == NULL)
{
hints.ai_flags = AI_PASSIVE;
}
// Populate address information // Populate address information
status = getaddrinfo(address, // e.g. "www.example.com" or IP status = getaddrinfo(address, // e.g. "www.example.com" or IP
@ -118,7 +201,7 @@ void GetAddressInformation(AddressInformation* outaddr, const char* address, con
// Did we succeed? // Did we succeed?
if (status != 0) if (status != 0)
{ {
TraceLog(LOG_WARNING, "Failed to get resolve host %s:%s: %ls", address, port, gai_strerror(status)); TraceLog(LOG_WARNING, "Failed to get resolve host %s:%s: %ls", address, port, gai_strerror(errno));
} }
else else
{ {
@ -141,6 +224,20 @@ void GetAddressInformation(AddressInformation* outaddr, const char* address, con
freeaddrinfo(results); freeaddrinfo(results);
} }
// IP helper method, checks if an address is a valid IPv4 address
bool IsIPv4Address(const char* address)
{
struct sockaddr_in sa;
return inet_pton(AF_INET, address, &(sa.sin_addr)) != 0;
}
// IP helper method, checks if an address is a valid IPv6 address
bool IsIPv6Address(const char* address)
{
struct sockaddr_in6 sa;
return inet_pton(AF_INET6, address, &(sa.sin6_addr)) != 0;
}
// Create a socket from information provided by the filled Address information struct // Create a socket from information provided by the filled Address information struct
bool CreateSocket(Socket* sock, const AddressInformation addr) bool CreateSocket(Socket* sock, const AddressInformation addr)
{ {
@ -150,7 +247,7 @@ bool CreateSocket(Socket* sock, const AddressInformation addr)
// Did we succeed? // Did we succeed?
if (sock->handle == INVALID_SOCKET) if (sock->handle == INVALID_SOCKET)
{ {
TraceLog(LOG_WARNING, "Failed to get create socket: %ls", gai_strerror(sock->handle)); TraceLog(LOG_WARNING, "Failed to get create socket: %ls", gai_strerror(errno));
CloseSocket(sock->handle); CloseSocket(sock->handle);
return false; return false;
} }
@ -173,7 +270,7 @@ bool BindSocket(Socket sock, const AddressInformation addr)
// Did we succeed? // Did we succeed?
if (status == SOCKET_ERROR) if (status == SOCKET_ERROR)
{ {
TraceLog(LOG_WARNING, "Failed to get bind socket: %ls", gai_strerror(status)); TraceLog(LOG_WARNING, "Failed to get bind socket: %ls", gai_strerror(errno));
return false; return false;
} }
else else
@ -194,7 +291,7 @@ bool ConnectSocket(Socket socket, AddressInformation addr)
// Did we succeed? // Did we succeed?
if (status == SOCKET_ERROR) if (status == SOCKET_ERROR)
{ {
TraceLog(LOG_WARNING, "Failed to connect socket: %ls", gai_strerror(status)); TraceLog(LOG_WARNING, "Failed to connect socket: %ls", gai_strerror(errno));
return false; return false;
} }
else else
@ -273,7 +370,7 @@ void CreateListenServer(Socket* tcpsock, const char* address, const char* port,
// Did we succeed? // Did we succeed?
if (status == -1) if (status == -1)
{ {
TraceLog(LOG_WARNING, "Failed to get resolve host %s:%s: %ls", address, port, gai_strerror(status)); TraceLog(LOG_WARNING, "Failed to get resolve host %s:%s: %ls", address, port, gai_strerror(errno));
} }
else else
{ {
@ -444,80 +541,11 @@ void ResetSocket(Socket* socket)
socket->blocking = false; socket->blocking = false;
}; };
// Resolve the hostname
void ResolveHost(const char* hostname)
{
struct addrinfo hints, *res, *p;
int status;
char ipstr[INET6_ADDRSTRLEN];
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
hints.ai_socktype = SOCK_STREAM;
if ((status = getaddrinfo(hostname, NULL, &hints, &res)) != 0)
{
TraceLog(LOG_WARNING, "getaddrinfo: %ls", gai_strerror(status));
return 2;
}
TraceLog(LOG_INFO, "IP addresses for %s:", hostname);
for (p = res; p != NULL; p = p->ai_next)
{
void* addr;
char* ipver;
// get the pointer to the address itself, different fields in IPv4 and IPv6:
if (p->ai_family == AF_INET)
{ // IPv4
struct sockaddr_in* ipv4 = (struct sockaddr_in*) p->ai_addr;
addr = &(ipv4->sin_addr);
ipver = "IPv4";
}
else
{ // IPv6
struct sockaddr_in6* ipv6 = (struct sockaddr_in6*) p->ai_addr;
addr = &(ipv6->sin6_addr);
ipver = "IPv6";
}
// convert the IP to a string and print it:
inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr);
TraceLog(LOG_INFO, "%s: %s", ipver, ipstr);
}
freeaddrinfo(res); // free the linked list
}
// Resolve the hostname
void ResolveIP(const char* ip)
{
struct hostent* he;
struct in_addr ipv4addr;
struct in6_addr ipv6addr;
inet_pton(AF_INET, ip, &ipv4addr);
he = gethostbyaddr(&ipv4addr, sizeof ipv4addr, AF_INET);
if (he != NULL)
{
printf("Host name: %s\n", he->h_name);
}
inet_pton(AF_INET6, ip, &ipv6addr);
he = gethostbyaddr(&ipv6addr, sizeof ipv6addr, AF_INET6);
if (he != NULL)
{
printf("Host name: %s\n", he->h_name);
}
}
// Print socket information // Print socket information
void PrintSocket(struct SocketAddress* addr, const int family, const int socktype, const int protocol) void PrintSocket(struct SocketAddress* addr, const int family, const int socktype, const int protocol)
{ {
struct sockaddr_in* sockaddr_ipv4;
struct sockaddr_in6* sockaddr_ipv6;
struct sockaddr* sockaddr_ip; struct sockaddr* sockaddr_ip;
char ip4[INET_ADDRSTRLEN]; // space to hold the IPv4 string char ip[INET6_ADDRSTRLEN]; // Enough pace to hold a IPv6 string
char ip6[INET6_ADDRSTRLEN]; // space to hold the IPv6 string
switch (family) switch (family)
{ {
case AF_UNSPEC: case AF_UNSPEC:
@ -528,13 +556,13 @@ void PrintSocket(struct SocketAddress* addr, const int family, const int socktyp
case AF_INET: case AF_INET:
{ {
TraceLog(LOG_DEBUG, "Family: AF_INET (IPv4)"); TraceLog(LOG_DEBUG, "Family: AF_INET (IPv4)");
TraceLog(LOG_INFO, "- IPv4 address %s", SocketAddressToString(addr, ip4)); TraceLog(LOG_INFO, "- IPv4 address %s", SocketAddressToString(addr, ip));
} }
break; break;
case AF_INET6: case AF_INET6:
{ {
TraceLog(LOG_DEBUG, "Family: AF_INET6 (IPv6)"); TraceLog(LOG_DEBUG, "Family: AF_INET6 (IPv6)");
TraceLog(LOG_INFO, "- IPv6 address %s", SocketAddressToString(addr, ip6)); TraceLog(LOG_INFO, "- IPv6 address %s", SocketAddressToString(addr, ip));
} }
break; break;
case AF_NETBIOS: case AF_NETBIOS:
@ -613,3 +641,344 @@ char* SocketAddressToString(struct SocketAddress* sockaddr, char buffer[])
break; break;
} }
} }
unsigned short HostToNetworkShort(unsigned short value)
{
return htons(value);
}
unsigned long HostToNetworkLong(unsigned long value)
{
return htonl(value);
}
unsigned int HostToNetworkFloat(float value)
{
return htonf(value);
}
unsigned long long HostToNetworkDouble(double value)
{
return htond(value);
}
unsigned long long HostToNetworkLongLong(unsigned long long value)
{
return htonll(value);
}
unsigned short NetworkToHostShort(unsigned short value)
{
return ntohs(value);
}
unsigned long NetworkToHostLong(unsigned long value)
{
return ntohl(value);
}
float NetworkToHostFloat(unsigned int value)
{
return ntohf(value);
}
double NetworkToHostDouble(unsigned long long value)
{
return ntohd(value);
}
double NetworkToHostLongDouble(unsigned long long value)
{
return ntohd(value);
}
unsigned long long NetworkToHostLongLong(unsigned long long value)
{
return ntohll(value);
}
/*
** PackData() -- store data dictated by the format string in the buffer
**
** bits |signed unsigned float string
** -----+----------------------------------
** 8 | c C
** 16 | h H f
** 32 | l L d
** 64 | q Q g
** - | s
**
** (16-bit unsigned length is automatically prepended to strings)
*/
unsigned int PackData(unsigned char* buf, char* format, ...)
{
va_list ap;
signed char c; // 8-bit
unsigned char C;
int h; // 16-bit
unsigned int H;
long int l; // 32-bit
unsigned long int L;
long long int q; // 64-bit
unsigned long long int Q;
float f; // floats
double d;
long double g;
unsigned long long int fhold;
char* s; // strings
unsigned int len;
unsigned int size = 0;
va_start(ap, format);
for (; *format != '\0'; format++)
{
switch (*format)
{
case 'c': // 8-bit
size += 1;
c = (signed char) va_arg(ap, int); // promoted
*buf++ = c;
break;
case 'C': // 8-bit unsigned
size += 1;
C = (unsigned char) va_arg(ap, unsigned int); // promoted
*buf++ = C;
break;
case 'h': // 16-bit
size += 2;
h = va_arg(ap, int);
packi16(buf, h);
buf += 2;
break;
case 'H': // 16-bit unsigned
size += 2;
H = va_arg(ap, unsigned int);
packi16(buf, H);
buf += 2;
break;
case 'l': // 32-bit
size += 4;
l = va_arg(ap, long int);
packi32(buf, l);
buf += 4;
break;
case 'L': // 32-bit unsigned
size += 4;
L = va_arg(ap, unsigned long int);
packi32(buf, L);
buf += 4;
break;
case 'q': // 64-bit
size += 8;
q = va_arg(ap, long long int);
packi64(buf, q);
buf += 8;
break;
case 'Q': // 64-bit unsigned
size += 8;
Q = va_arg(ap, unsigned long long int);
packi64(buf, Q);
buf += 8;
break;
case 'f': // float-16
size += 2;
f = (float) va_arg(ap, double); // promoted
fhold = pack754_16(f); // convert to IEEE 754
packi16(buf, fhold);
buf += 2;
break;
case 'd': // float-32
size += 4;
d = va_arg(ap, double);
fhold = pack754_32(d); // convert to IEEE 754
packi32(buf, fhold);
buf += 4;
break;
case 'g': // float-64
size += 8;
g = va_arg(ap, long double);
fhold = pack754_64(g); // convert to IEEE 754
packi64(buf, fhold);
buf += 8;
break;
case 's': // string
s = va_arg(ap, char*);
len = strlen(s);
size += len + 2;
packi16(buf, len);
buf += 2;
memcpy(buf, s, len);
buf += len;
break;
}
}
va_end(ap);
return size;
}
/*
** UnpackData() -- unpack data dictated by the format string into the buffer
**
** bits |signed unsigned float string
** -----+----------------------------------
** 8 | c C
** 16 | h H f
** 32 | l L d
** 64 | q Q g
** - | s
**
** (string is extracted based on its stored length, but 's' can be
** prepended with a max length)
*/
void UnpackData(unsigned char* buf, char* format, ...)
{
va_list ap;
signed char* c; // 8-bit
unsigned char* C;
int* h; // 16-bit
unsigned int* H;
long int* l; // 32-bit
unsigned long int* L;
long long int* q; // 64-bit
unsigned long long int* Q;
float* f; // floats
double* d;
long double* g;
unsigned long long int fhold;
char* s;
unsigned int len, maxstrlen = 0, count;
va_start(ap, format);
for (; *format != '\0'; format++)
{
switch (*format)
{
case 'c': // 8-bit
c = va_arg(ap, signed char*);
if (*buf <= 0x7f)
{
*c = *buf;
} // re-sign
else
{
*c = -1 - (unsigned char) (0xffu - *buf);
}
buf++;
break;
case 'C': // 8-bit unsigned
C = va_arg(ap, unsigned char*);
*C = *buf++;
break;
case 'h': // 16-bit
h = va_arg(ap, int*);
*h = unpacki16(buf);
buf += 2;
break;
case 'H': // 16-bit unsigned
H = va_arg(ap, unsigned int*);
*H = unpacku16(buf);
buf += 2;
break;
case 'l': // 32-bit
l = va_arg(ap, long int*);
*l = unpacki32(buf);
buf += 4;
break;
case 'L': // 32-bit unsigned
L = va_arg(ap, unsigned long int*);
*L = unpacku32(buf);
buf += 4;
break;
case 'q': // 64-bit
q = va_arg(ap, long long int*);
*q = unpacki64(buf);
buf += 8;
break;
case 'Q': // 64-bit unsigned
Q = va_arg(ap, unsigned long long int*);
*Q = unpacku64(buf);
buf += 8;
break;
case 'f': // float
f = va_arg(ap, float*);
fhold = unpacku16(buf);
*f = unpack754_16(fhold);
buf += 2;
break;
case 'd': // float-32
d = va_arg(ap, double*);
fhold = unpacku32(buf);
*d = unpack754_32(fhold);
buf += 4;
break;
case 'g': // float-64
g = va_arg(ap, long double*);
fhold = unpacku64(buf);
*g = unpack754_64(fhold);
buf += 8;
break;
case 's': // string
s = va_arg(ap, char*);
len = unpacku16(buf);
buf += 2;
if (maxstrlen > 0 && len > maxstrlen)
count = maxstrlen - 1;
else
count = len;
memcpy(s, buf, count);
s[count] = '\0';
buf += len;
break;
default:
if (isdigit(*format))
{ // track max str len
maxstrlen = maxstrlen * 10 + (*format - '0');
}
}
if (!isdigit(*format))
maxstrlen = 0;
}
va_end(ap);
}

221
src/rpack.h Normal file
View File

@ -0,0 +1,221 @@
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
// macros for packing floats and doubles:
#define pack754_16(f) (pack754((f), 16, 5))
#define pack754_32(f) (pack754((f), 32, 8))
#define pack754_64(f) (pack754((f), 64, 11))
#define unpack754_16(i) (unpack754((i), 16, 5))
#define unpack754_32(i) (unpack754((i), 32, 8))
#define unpack754_64(i) (unpack754((i), 64, 11))
/*
** pack754() -- pack a floating point number into IEEE-754 format
*/
unsigned long long int pack754(long double f, unsigned bits, unsigned expbits)
{
long double fnorm;
int shift;
long long sign, exp, significand;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (f == 0.0)
return 0; // get this special case out of the way
// check sign and begin normalization
if (f < 0)
{
sign = 1;
fnorm = -f;
}
else
{
sign = 0;
fnorm = f;
}
// get the normalized form of f and track the exponent
shift = 0;
while (fnorm >= 2.0)
{
fnorm /= 2.0;
shift++;
}
while (fnorm < 1.0)
{
fnorm *= 2.0;
shift--;
}
fnorm = fnorm - 1.0;
// calculate the binary form (non-float) of the significand data
significand = fnorm * ((1LL << significandbits) + 0.5f);
// get the biased exponent
exp = shift + ((1 << (expbits - 1)) - 1); // shift + bias
// return the final answer
return (sign << (bits - 1)) | (exp << (bits - expbits - 1)) | significand;
}
/*
** unpack754() -- unpack a floating point number from IEEE-754 format
*/
long double unpack754(unsigned long long int i, unsigned bits, unsigned expbits)
{
long double result;
long long shift;
unsigned bias;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (i == 0)
return 0.0;
// pull the significand
result = (i & ((1LL << significandbits) - 1)); // mask
result /= (1LL << significandbits); // convert back to float
result += 1.0f; // add the one back on
// deal with the exponent
bias = (1 << (expbits - 1)) - 1;
shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
while (shift > 0)
{
result *= 2.0;
shift--;
}
while (shift < 0)
{
result /= 2.0;
shift++;
}
// sign it
result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
return result;
}
/*
** packi16() -- store a 16-bit int into a char buffer (like htons())
*/
void packi16(unsigned char* buf, unsigned int i)
{
*buf++ = i >> 8;
*buf++ = i;
}
/*
** packi32() -- store a 32-bit int into a char buffer (like htonl())
*/
void packi32(unsigned char* buf, unsigned long int i)
{
*buf++ = i >> 24;
*buf++ = i >> 16;
*buf++ = i >> 8;
*buf++ = i;
}
/*
** packi64() -- store a 64-bit int into a char buffer (like htonl())
*/
void packi64(unsigned char* buf, unsigned long long int i)
{
*buf++ = i >> 56;
*buf++ = i >> 48;
*buf++ = i >> 40;
*buf++ = i >> 32;
*buf++ = i >> 24;
*buf++ = i >> 16;
*buf++ = i >> 8;
*buf++ = i;
}
/*
** unpacki16() -- unpack a 16-bit int from a char buffer (like ntohs())
*/
int unpacki16(unsigned char* buf)
{
unsigned int i2 = ((unsigned int) buf[0] << 8) | buf[1];
int i;
// change unsigned numbers to signed
if (i2 <= 0x7fffu)
{
i = i2;
}
else
{
i = -1 - (unsigned int) (0xffffu - i2);
}
return i;
}
/*
** unpacku16() -- unpack a 16-bit unsigned from a char buffer (like ntohs())
*/
unsigned int unpacku16(unsigned char* buf)
{
return ((unsigned int) buf[0] << 8) | buf[1];
}
/*
** unpacki32() -- unpack a 32-bit int from a char buffer (like ntohl())
*/
long int unpacki32(unsigned char* buf)
{
unsigned long int i2 = ((unsigned long int) buf[0] << 24) | ((unsigned long int) buf[1] << 16) | ((unsigned long int) buf[2] << 8) | buf[3];
long int i;
// change unsigned numbers to signed
if (i2 <= 0x7fffffffu)
{
i = i2;
}
else
{
i = -1 - (long int) (0xffffffffu - i2);
}
return i;
}
/*
** unpacku32() -- unpack a 32-bit unsigned from a char buffer (like ntohl())
*/
unsigned long int unpacku32(unsigned char* buf)
{
return ((unsigned long int) buf[0] << 24) | ((unsigned long int) buf[1] << 16) | ((unsigned long int) buf[2] << 8) | buf[3];
}
/*
** unpacki64() -- unpack a 64-bit int from a char buffer (like ntohl())
*/
long long int unpacki64(unsigned char* buf)
{
unsigned long long int i2 = ((unsigned long long int) buf[0] << 56) | ((unsigned long long int) buf[1] << 48) | ((unsigned long long int) buf[2] << 40) | ((unsigned long long int) buf[3] << 32) | ((unsigned long long int) buf[4] << 24) | ((unsigned long long int) buf[5] << 16) | ((unsigned long long int) buf[6] << 8) | buf[7];
long long int i;
// change unsigned numbers to signed
if (i2 <= 0x7fffffffffffffffu)
{
i = i2;
}
else
{
i = -1 - (long long int) (0xffffffffffffffffu - i2);
}
return i;
}
/*
** unpacku64() -- unpack a 64-bit unsigned from a char buffer (like ntohl())
*/
unsigned long long int unpacku64(unsigned char* buf)
{
return ((unsigned long long int) buf[0] << 56) | ((unsigned long long int) buf[1] << 48) | ((unsigned long long int) buf[2] << 40) | ((unsigned long long int) buf[3] << 32) | ((unsigned long long int) buf[4] << 24) | ((unsigned long long int) buf[5] << 16) | ((unsigned long long int) buf[6] << 8) | buf[7];
}

View File

@ -45,7 +45,6 @@
#define MMNOSOUND #define MMNOSOUND
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Platform defines // Platform defines
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------