diff options
-rw-r--r-- | .gitignore | 12 | ||||
-rw-r--r-- | Lua51.props | 28 | ||||
-rw-r--r-- | Lua52.props | 28 | ||||
-rwxr-xr-x | mime.vcxproj | 54 | ||||
-rw-r--r-- | mime.vcxproj.filters | 16 | ||||
-rwxr-xr-x | socket.vcxproj | 133 | ||||
-rw-r--r-- | socket.vcxproj.filters | 51 | ||||
-rw-r--r-- | src/inet.c | 78 | ||||
-rw-r--r-- | src/inet.h | 7 | ||||
-rw-r--r-- | src/io.h | 2 | ||||
-rw-r--r-- | src/makefile | 41 | ||||
-rw-r--r-- | src/udp.c | 122 | ||||
-rw-r--r-- | src/wsocket.c | 29 |
13 files changed, 435 insertions, 166 deletions
@@ -1,4 +1,16 @@ | |||
1 | *.o | 1 | *.o |
2 | *.so | 2 | *.so |
3 | *.so.* | 3 | *.so.* |
4 | *.obj | ||
5 | *.lib | ||
6 | *.dll* | ||
7 | *.user | ||
8 | *.sdf | ||
9 | Lua.props | ||
10 | Debug | ||
11 | Release | ||
12 | *.manifest | ||
13 | *.swp | ||
14 | *.suo | ||
15 | x64 | ||
4 | 16 | ||
diff --git a/Lua51.props b/Lua51.props new file mode 100644 index 0000000..1bd6256 --- /dev/null +++ b/Lua51.props | |||
@@ -0,0 +1,28 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | <ImportGroup Label="PropertySheets" /> | ||
4 | <PropertyGroup Label="UserMacros"> | ||
5 | <LUABIN_PATH>..\build\vc12\bin\lua\5.1\</LUABIN_PATH> | ||
6 | <LUALIB_PATH>..\build\vc12\bin\lua\5.1\</LUALIB_PATH> | ||
7 | <LUAINC_PATH>..\build\vc12\include\lua\5.1\</LUAINC_PATH> | ||
8 | <LUALIB>lua51.lib</LUALIB> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup> | ||
11 | <_PropertySheetDisplayName>Lua51</_PropertySheetDisplayName> | ||
12 | </PropertyGroup> | ||
13 | <ItemDefinitionGroup /> | ||
14 | <ItemGroup> | ||
15 | <BuildMacro Include="LUALIB_PATH"> | ||
16 | <Value>$(LUALIB_PATH)</Value> | ||
17 | </BuildMacro> | ||
18 | <BuildMacro Include="LUABIN_PATH"> | ||
19 | <Value>$(LUABIN_PATH)</Value> | ||
20 | </BuildMacro> | ||
21 | <BuildMacro Include="LUAINC_PATH"> | ||
22 | <Value>$(LUAINC_PATH)</Value> | ||
23 | </BuildMacro> | ||
24 | <BuildMacro Include="LUALIB"> | ||
25 | <Value>$(LUALIB)</Value> | ||
26 | </BuildMacro> | ||
27 | </ItemGroup> | ||
28 | </Project> | ||
diff --git a/Lua52.props b/Lua52.props new file mode 100644 index 0000000..01afcfa --- /dev/null +++ b/Lua52.props | |||
@@ -0,0 +1,28 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | <ImportGroup Label="PropertySheets" /> | ||
4 | <PropertyGroup Label="UserMacros"> | ||
5 | <LUABIN_PATH>..\build\vc12\bin\lua\5.2\</LUABIN_PATH> | ||
6 | <LUALIB_PATH>..\build\vc12\bin\lua\5.2\</LUALIB_PATH> | ||
7 | <LUAINC_PATH>..\build\vc12\include\lua\5.2\</LUAINC_PATH> | ||
8 | <LUALIB>lua52.lib</LUALIB> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup> | ||
11 | <_PropertySheetDisplayName>Lua52</_PropertySheetDisplayName> | ||
12 | </PropertyGroup> | ||
13 | <ItemDefinitionGroup /> | ||
14 | <ItemGroup> | ||
15 | <BuildMacro Include="LUALIB_PATH"> | ||
16 | <Value>$(LUALIB_PATH)</Value> | ||
17 | </BuildMacro> | ||
18 | <BuildMacro Include="LUABIN_PATH"> | ||
19 | <Value>$(LUABIN_PATH)</Value> | ||
20 | </BuildMacro> | ||
21 | <BuildMacro Include="LUAINC_PATH"> | ||
22 | <Value>$(LUAINC_PATH)</Value> | ||
23 | </BuildMacro> | ||
24 | <BuildMacro Include="LUALIB"> | ||
25 | <Value>$(LUALIB)</Value> | ||
26 | </BuildMacro> | ||
27 | </ItemGroup> | ||
28 | </Project> | ||
diff --git a/mime.vcxproj b/mime.vcxproj index 95781f2..63f5452 100755 --- a/mime.vcxproj +++ b/mime.vcxproj | |||
@@ -21,6 +21,19 @@ | |||
21 | <ItemGroup> | 21 | <ItemGroup> |
22 | <ClCompile Include="src\mime.c" /> | 22 | <ClCompile Include="src\mime.c" /> |
23 | </ItemGroup> | 23 | </ItemGroup> |
24 | <ItemGroup> | ||
25 | <CustomBuild Include="src\mime.lua"> | ||
26 | <FileType>Document</FileType> | ||
27 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command> | ||
28 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
29 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command> | ||
30 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
31 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUALIB_PATH)$(Platform)\$(Configuration)</Command> | ||
32 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUALIB_PATH)$(Platform)\$(Configuration)</Command> | ||
33 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
34 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
35 | </CustomBuild> | ||
36 | </ItemGroup> | ||
24 | <PropertyGroup Label="Globals"> | 37 | <PropertyGroup Label="Globals"> |
25 | <ProjectGuid>{128E8BD0-174A-48F0-8771-92B1E8D18713}</ProjectGuid> | 38 | <ProjectGuid>{128E8BD0-174A-48F0-8771-92B1E8D18713}</ProjectGuid> |
26 | <Keyword>Win32Proj</Keyword> | 39 | <Keyword>Win32Proj</Keyword> |
@@ -52,25 +65,29 @@ | |||
52 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> | 65 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> |
53 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 66 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
54 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 67 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
68 | <Import Project="Lua.props" /> | ||
55 | </ImportGroup> | 69 | </ImportGroup> |
56 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> | 70 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> |
57 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 71 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
58 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 72 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
73 | <Import Project="Lua.props" /> | ||
59 | </ImportGroup> | 74 | </ImportGroup> |
60 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> | 75 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> |
61 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 76 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
62 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 77 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
78 | <Import Project="Lua.props" /> | ||
63 | </ImportGroup> | 79 | </ImportGroup> |
64 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> | 80 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> |
65 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 81 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
66 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 82 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
83 | <Import Project="Lua.props" /> | ||
67 | </ImportGroup> | 84 | </ImportGroup> |
68 | <PropertyGroup Label="UserMacros" /> | 85 | <PropertyGroup Label="UserMacros" /> |
69 | <PropertyGroup> | 86 | <PropertyGroup> |
70 | <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion> | 87 | <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion> |
71 | </PropertyGroup> | 88 | </PropertyGroup> |
72 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | 89 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
73 | <OutDir>$(SolutionDir)\$(Configuration)\mime\</OutDir> | 90 | <OutDir>$(LUABIN_PATH)$(Configuration)\mime\</OutDir> |
74 | <IntDir>$(Configuration)\</IntDir> | 91 | <IntDir>$(Configuration)\</IntDir> |
75 | <LinkIncremental>true</LinkIncremental> | 92 | <LinkIncremental>true</LinkIncremental> |
76 | <TargetName>core</TargetName> | 93 | <TargetName>core</TargetName> |
@@ -78,23 +95,23 @@ | |||
78 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | 95 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
79 | <LinkIncremental>true</LinkIncremental> | 96 | <LinkIncremental>true</LinkIncremental> |
80 | <TargetName>core</TargetName> | 97 | <TargetName>core</TargetName> |
81 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mime\</OutDir> | 98 | <OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\mime\</OutDir> |
82 | </PropertyGroup> | 99 | </PropertyGroup> |
83 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | 100 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
84 | <OutDir>$(SolutionDir)\$(Configuration)\mime\</OutDir> | 101 | <OutDir>$(LUABIN_PATH)$(Configuration)\mime\</OutDir> |
85 | <IntDir>$(Configuration)\</IntDir> | 102 | <IntDir>$(Configuration)\</IntDir> |
86 | <LinkIncremental>false</LinkIncremental> | 103 | <LinkIncremental>false</LinkIncremental> |
87 | <TargetName>core</TargetName> | 104 | <TargetName>core</TargetName> |
88 | </PropertyGroup> | 105 | </PropertyGroup> |
89 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 106 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
90 | <LinkIncremental>false</LinkIncremental> | 107 | <LinkIncremental>false</LinkIncremental> |
91 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mime\</OutDir> | 108 | <OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\mime\</OutDir> |
92 | <TargetName>core</TargetName> | 109 | <TargetName>core</TargetName> |
93 | </PropertyGroup> | 110 | </PropertyGroup> |
94 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | 111 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
95 | <ClCompile> | 112 | <ClCompile> |
96 | <Optimization>Disabled</Optimization> | 113 | <Optimization>Disabled</Optimization> |
97 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 114 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
98 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 115 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
99 | <MinimalRebuild>true</MinimalRebuild> | 116 | <MinimalRebuild>true</MinimalRebuild> |
100 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> | 117 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
@@ -102,11 +119,12 @@ | |||
102 | <PrecompiledHeader /> | 119 | <PrecompiledHeader /> |
103 | <WarningLevel>Level3</WarningLevel> | 120 | <WarningLevel>Level3</WarningLevel> |
104 | <DebugInformationFormat>EditAndContinue</DebugInformationFormat> | 121 | <DebugInformationFormat>EditAndContinue</DebugInformationFormat> |
122 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
105 | </ClCompile> | 123 | </ClCompile> |
106 | <Link> | 124 | <Link> |
107 | <AdditionalDependencies>lualib.lib;%(AdditionalDependencies)</AdditionalDependencies> | 125 | <AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies> |
108 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 126 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
109 | <AdditionalLibraryDirectories>..\bin\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 127 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
110 | <GenerateDebugInformation>true</GenerateDebugInformation> | 128 | <GenerateDebugInformation>true</GenerateDebugInformation> |
111 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> | 129 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> |
112 | <SubSystem>Windows</SubSystem> | 130 | <SubSystem>Windows</SubSystem> |
@@ -114,12 +132,13 @@ | |||
114 | <DataExecutionPrevention /> | 132 | <DataExecutionPrevention /> |
115 | <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary> | 133 | <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary> |
116 | <TargetMachine>MachineX86</TargetMachine> | 134 | <TargetMachine>MachineX86</TargetMachine> |
135 | <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> | ||
117 | </Link> | 136 | </Link> |
118 | </ItemDefinitionGroup> | 137 | </ItemDefinitionGroup> |
119 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | 138 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
120 | <ClCompile> | 139 | <ClCompile> |
121 | <Optimization>Disabled</Optimization> | 140 | <Optimization>Disabled</Optimization> |
122 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 141 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
123 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 142 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
124 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> | 143 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
125 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | 144 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
@@ -127,11 +146,12 @@ | |||
127 | </PrecompiledHeader> | 146 | </PrecompiledHeader> |
128 | <WarningLevel>Level3</WarningLevel> | 147 | <WarningLevel>Level3</WarningLevel> |
129 | <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> | 148 | <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
149 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
130 | </ClCompile> | 150 | </ClCompile> |
131 | <Link> | 151 | <Link> |
132 | <AdditionalDependencies>lualib.lib;%(AdditionalDependencies)</AdditionalDependencies> | 152 | <AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies> |
133 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 153 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
134 | <AdditionalLibraryDirectories>..\bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 154 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
135 | <GenerateDebugInformation>true</GenerateDebugInformation> | 155 | <GenerateDebugInformation>true</GenerateDebugInformation> |
136 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> | 156 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> |
137 | <SubSystem>Windows</SubSystem> | 157 | <SubSystem>Windows</SubSystem> |
@@ -143,17 +163,18 @@ | |||
143 | </ItemDefinitionGroup> | 163 | </ItemDefinitionGroup> |
144 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | 164 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
145 | <ClCompile> | 165 | <ClCompile> |
146 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 166 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
147 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 167 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
148 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | 168 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
149 | <PrecompiledHeader /> | 169 | <PrecompiledHeader /> |
150 | <WarningLevel>Level4</WarningLevel> | 170 | <WarningLevel>Level4</WarningLevel> |
151 | <DebugInformationFormat /> | 171 | <DebugInformationFormat /> |
172 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
152 | </ClCompile> | 173 | </ClCompile> |
153 | <Link> | 174 | <Link> |
154 | <AdditionalDependencies>lualib.lib;%(AdditionalDependencies)</AdditionalDependencies> | 175 | <AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies> |
155 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 176 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
156 | <AdditionalLibraryDirectories>..\bin\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 177 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
157 | <GenerateDebugInformation>true</GenerateDebugInformation> | 178 | <GenerateDebugInformation>true</GenerateDebugInformation> |
158 | <SubSystem>Windows</SubSystem> | 179 | <SubSystem>Windows</SubSystem> |
159 | <OptimizeReferences>true</OptimizeReferences> | 180 | <OptimizeReferences>true</OptimizeReferences> |
@@ -166,7 +187,7 @@ | |||
166 | </ItemDefinitionGroup> | 187 | </ItemDefinitionGroup> |
167 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 188 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
168 | <ClCompile> | 189 | <ClCompile> |
169 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 190 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
170 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 191 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
171 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | 192 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
172 | <PrecompiledHeader> | 193 | <PrecompiledHeader> |
@@ -174,11 +195,12 @@ | |||
174 | <WarningLevel>Level4</WarningLevel> | 195 | <WarningLevel>Level4</WarningLevel> |
175 | <DebugInformationFormat> | 196 | <DebugInformationFormat> |
176 | </DebugInformationFormat> | 197 | </DebugInformationFormat> |
198 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
177 | </ClCompile> | 199 | </ClCompile> |
178 | <Link> | 200 | <Link> |
179 | <AdditionalDependencies>lualib.lib;%(AdditionalDependencies)</AdditionalDependencies> | 201 | <AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies> |
180 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 202 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
181 | <AdditionalLibraryDirectories>..\bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 203 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
182 | <GenerateDebugInformation>true</GenerateDebugInformation> | 204 | <GenerateDebugInformation>true</GenerateDebugInformation> |
183 | <SubSystem>Windows</SubSystem> | 205 | <SubSystem>Windows</SubSystem> |
184 | <OptimizeReferences>true</OptimizeReferences> | 206 | <OptimizeReferences>true</OptimizeReferences> |
diff --git a/mime.vcxproj.filters b/mime.vcxproj.filters new file mode 100644 index 0000000..621215b --- /dev/null +++ b/mime.vcxproj.filters | |||
@@ -0,0 +1,16 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | <ItemGroup> | ||
4 | <ClCompile Include="src\mime.c" /> | ||
5 | </ItemGroup> | ||
6 | <ItemGroup> | ||
7 | <Filter Include="cdir"> | ||
8 | <UniqueIdentifier>{fad87a86-297c-4881-a114-73b967bb3c92}</UniqueIdentifier> | ||
9 | </Filter> | ||
10 | </ItemGroup> | ||
11 | <ItemGroup> | ||
12 | <CustomBuild Include="src\mime.lua"> | ||
13 | <Filter>cdir</Filter> | ||
14 | </CustomBuild> | ||
15 | </ItemGroup> | ||
16 | </Project> \ No newline at end of file | ||
diff --git a/socket.vcxproj b/socket.vcxproj index 0256c90..307a8ae 100755 --- a/socket.vcxproj +++ b/socket.vcxproj | |||
@@ -32,6 +32,98 @@ | |||
32 | <ClCompile Include="src\udp.c" /> | 32 | <ClCompile Include="src\udp.c" /> |
33 | <ClCompile Include="src\wsocket.c" /> | 33 | <ClCompile Include="src\wsocket.c" /> |
34 | </ItemGroup> | 34 | </ItemGroup> |
35 | <ItemGroup> | ||
36 | <CustomBuild Include="src\ltn12.lua"> | ||
37 | <FileType>Document</FileType> | ||
38 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command> | ||
39 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command> | ||
40 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command> | ||
41 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command> | ||
42 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
43 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
44 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
45 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
46 | </CustomBuild> | ||
47 | <CustomBuild Include="src\socket.lua"> | ||
48 | <FileType>Document</FileType> | ||
49 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command> | ||
50 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command> | ||
51 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command> | ||
52 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command> | ||
53 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
54 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
55 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
56 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs> | ||
57 | </CustomBuild> | ||
58 | </ItemGroup> | ||
59 | <ItemGroup> | ||
60 | <CustomBuild Include="src\ftp.lua"> | ||
61 | <FileType>Document</FileType> | ||
62 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
63 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
64 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
65 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
66 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
67 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
68 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
69 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
70 | </CustomBuild> | ||
71 | <CustomBuild Include="src\headers.lua"> | ||
72 | <FileType>Document</FileType> | ||
73 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
74 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
75 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
76 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
77 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
78 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
79 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
80 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
81 | </CustomBuild> | ||
82 | <CustomBuild Include="src\http.lua"> | ||
83 | <FileType>Document</FileType> | ||
84 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
85 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
86 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
87 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
88 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
89 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
90 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
91 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
92 | </CustomBuild> | ||
93 | <CustomBuild Include="src\smtp.lua"> | ||
94 | <FileType>Document</FileType> | ||
95 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
96 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
97 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
98 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
99 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
100 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
101 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
102 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
103 | </CustomBuild> | ||
104 | <CustomBuild Include="src\tp.lua"> | ||
105 | <FileType>Document</FileType> | ||
106 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
107 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
108 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
109 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
110 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
111 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
112 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
113 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
114 | </CustomBuild> | ||
115 | <CustomBuild Include="src\url.lua"> | ||
116 | <FileType>Document</FileType> | ||
117 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
118 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
119 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
120 | <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs> | ||
121 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
122 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command> | ||
123 | <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
124 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command> | ||
125 | </CustomBuild> | ||
126 | </ItemGroup> | ||
35 | <PropertyGroup Label="Globals"> | 127 | <PropertyGroup Label="Globals"> |
36 | <ProjectGuid>{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}</ProjectGuid> | 128 | <ProjectGuid>{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}</ProjectGuid> |
37 | <Keyword>Win32Proj</Keyword> | 129 | <Keyword>Win32Proj</Keyword> |
@@ -63,25 +155,29 @@ | |||
63 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> | 155 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> |
64 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 156 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
65 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 157 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
158 | <Import Project="Lua.props" /> | ||
66 | </ImportGroup> | 159 | </ImportGroup> |
67 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> | 160 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> |
68 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 161 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
69 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 162 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
163 | <Import Project="Lua.props" /> | ||
70 | </ImportGroup> | 164 | </ImportGroup> |
71 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> | 165 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> |
72 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 166 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
73 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 167 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
168 | <Import Project="Lua.props" /> | ||
74 | </ImportGroup> | 169 | </ImportGroup> |
75 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> | 170 | <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> |
76 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | 171 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
77 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> | 172 | <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> |
173 | <Import Project="Lua.props" /> | ||
78 | </ImportGroup> | 174 | </ImportGroup> |
79 | <PropertyGroup Label="UserMacros" /> | 175 | <PropertyGroup Label="UserMacros" /> |
80 | <PropertyGroup> | 176 | <PropertyGroup> |
81 | <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion> | 177 | <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion> |
82 | </PropertyGroup> | 178 | </PropertyGroup> |
83 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | 179 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
84 | <OutDir>$(SolutionDir)\$(Configuration)\socket\</OutDir> | 180 | <OutDir>$(LUALIB_PATH)$(Configuration)\socket\</OutDir> |
85 | <IntDir>$(Configuration)\</IntDir> | 181 | <IntDir>$(Configuration)\</IntDir> |
86 | <LinkIncremental>true</LinkIncremental> | 182 | <LinkIncremental>true</LinkIncremental> |
87 | <TargetName>core</TargetName> | 183 | <TargetName>core</TargetName> |
@@ -89,23 +185,23 @@ | |||
89 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | 185 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
90 | <LinkIncremental>true</LinkIncremental> | 186 | <LinkIncremental>true</LinkIncremental> |
91 | <TargetName>core</TargetName> | 187 | <TargetName>core</TargetName> |
92 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\socket\</OutDir> | 188 | <OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\</OutDir> |
93 | </PropertyGroup> | 189 | </PropertyGroup> |
94 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | 190 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
95 | <OutDir>$(SolutionDir)\$(Configuration)\socket\</OutDir> | 191 | <OutDir>$(LUALIB_PATH)$(Configuration)\socket\</OutDir> |
96 | <IntDir>$(Configuration)\</IntDir> | 192 | <IntDir>$(Configuration)\</IntDir> |
97 | <LinkIncremental>false</LinkIncremental> | 193 | <LinkIncremental>false</LinkIncremental> |
98 | <TargetName>core</TargetName> | 194 | <TargetName>core</TargetName> |
99 | </PropertyGroup> | 195 | </PropertyGroup> |
100 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 196 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
101 | <LinkIncremental>false</LinkIncremental> | 197 | <LinkIncremental>false</LinkIncremental> |
102 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\socket\</OutDir> | 198 | <OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\</OutDir> |
103 | <TargetName>core</TargetName> | 199 | <TargetName>core</TargetName> |
104 | </PropertyGroup> | 200 | </PropertyGroup> |
105 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | 201 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
106 | <ClCompile> | 202 | <ClCompile> |
107 | <Optimization>Disabled</Optimization> | 203 | <Optimization>Disabled</Optimization> |
108 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 204 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
109 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 205 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
110 | <MinimalRebuild>true</MinimalRebuild> | 206 | <MinimalRebuild>true</MinimalRebuild> |
111 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> | 207 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
@@ -113,11 +209,12 @@ | |||
113 | <PrecompiledHeader /> | 209 | <PrecompiledHeader /> |
114 | <WarningLevel>Level3</WarningLevel> | 210 | <WarningLevel>Level3</WarningLevel> |
115 | <DebugInformationFormat>EditAndContinue</DebugInformationFormat> | 211 | <DebugInformationFormat>EditAndContinue</DebugInformationFormat> |
212 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
116 | </ClCompile> | 213 | </ClCompile> |
117 | <Link> | 214 | <Link> |
118 | <AdditionalDependencies>lualib.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> | 215 | <AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
119 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 216 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
120 | <AdditionalLibraryDirectories>..\bin\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 217 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
121 | <GenerateDebugInformation>true</GenerateDebugInformation> | 218 | <GenerateDebugInformation>true</GenerateDebugInformation> |
122 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> | 219 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> |
123 | <SubSystem>Windows</SubSystem> | 220 | <SubSystem>Windows</SubSystem> |
@@ -125,12 +222,13 @@ | |||
125 | <DataExecutionPrevention /> | 222 | <DataExecutionPrevention /> |
126 | <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary> | 223 | <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary> |
127 | <TargetMachine>MachineX86</TargetMachine> | 224 | <TargetMachine>MachineX86</TargetMachine> |
225 | <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> | ||
128 | </Link> | 226 | </Link> |
129 | </ItemDefinitionGroup> | 227 | </ItemDefinitionGroup> |
130 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | 228 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
131 | <ClCompile> | 229 | <ClCompile> |
132 | <Optimization>Disabled</Optimization> | 230 | <Optimization>Disabled</Optimization> |
133 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 231 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
134 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 232 | <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
135 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> | 233 | <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> |
136 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | 234 | <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
@@ -138,11 +236,12 @@ | |||
138 | </PrecompiledHeader> | 236 | </PrecompiledHeader> |
139 | <WarningLevel>Level3</WarningLevel> | 237 | <WarningLevel>Level3</WarningLevel> |
140 | <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> | 238 | <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
239 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
141 | </ClCompile> | 240 | </ClCompile> |
142 | <Link> | 241 | <Link> |
143 | <AdditionalDependencies>lualib.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> | 242 | <AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
144 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 243 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
145 | <AdditionalLibraryDirectories>..\bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 244 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
146 | <GenerateDebugInformation>true</GenerateDebugInformation> | 245 | <GenerateDebugInformation>true</GenerateDebugInformation> |
147 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> | 246 | <ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile> |
148 | <SubSystem>Windows</SubSystem> | 247 | <SubSystem>Windows</SubSystem> |
@@ -154,17 +253,18 @@ | |||
154 | </ItemDefinitionGroup> | 253 | </ItemDefinitionGroup> |
155 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | 254 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
156 | <ClCompile> | 255 | <ClCompile> |
157 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 256 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
158 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 257 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
159 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | 258 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
160 | <PrecompiledHeader /> | 259 | <PrecompiledHeader /> |
161 | <WarningLevel>Level4</WarningLevel> | 260 | <WarningLevel>Level4</WarningLevel> |
162 | <DebugInformationFormat /> | 261 | <DebugInformationFormat /> |
262 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
163 | </ClCompile> | 263 | </ClCompile> |
164 | <Link> | 264 | <Link> |
165 | <AdditionalDependencies>lualib.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> | 265 | <AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
166 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 266 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
167 | <AdditionalLibraryDirectories>..\bin\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 267 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
168 | <GenerateDebugInformation>true</GenerateDebugInformation> | 268 | <GenerateDebugInformation>true</GenerateDebugInformation> |
169 | <SubSystem>Windows</SubSystem> | 269 | <SubSystem>Windows</SubSystem> |
170 | <OptimizeReferences>true</OptimizeReferences> | 270 | <OptimizeReferences>true</OptimizeReferences> |
@@ -177,7 +277,7 @@ | |||
177 | </ItemDefinitionGroup> | 277 | </ItemDefinitionGroup> |
178 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 278 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
179 | <ClCompile> | 279 | <ClCompile> |
180 | <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 280 | <AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
181 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 281 | <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_MODULE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
182 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | 282 | <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
183 | <PrecompiledHeader> | 283 | <PrecompiledHeader> |
@@ -185,11 +285,12 @@ | |||
185 | <WarningLevel>Level4</WarningLevel> | 285 | <WarningLevel>Level4</WarningLevel> |
186 | <DebugInformationFormat> | 286 | <DebugInformationFormat> |
187 | </DebugInformationFormat> | 287 | </DebugInformationFormat> |
288 | <ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName> | ||
188 | </ClCompile> | 289 | </ClCompile> |
189 | <Link> | 290 | <Link> |
190 | <AdditionalDependencies>lualib.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> | 291 | <AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
191 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> | 292 | <OutputFile>$(OutDir)$(TargetName).dll</OutputFile> |
192 | <AdditionalLibraryDirectories>..\bin\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | 293 | <AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
193 | <GenerateDebugInformation>true</GenerateDebugInformation> | 294 | <GenerateDebugInformation>true</GenerateDebugInformation> |
194 | <SubSystem>Windows</SubSystem> | 295 | <SubSystem>Windows</SubSystem> |
195 | <OptimizeReferences>true</OptimizeReferences> | 296 | <OptimizeReferences>true</OptimizeReferences> |
diff --git a/socket.vcxproj.filters b/socket.vcxproj.filters new file mode 100644 index 0000000..38f2f07 --- /dev/null +++ b/socket.vcxproj.filters | |||
@@ -0,0 +1,51 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | <ItemGroup> | ||
4 | <ClCompile Include="src\auxiliar.c" /> | ||
5 | <ClCompile Include="src\buffer.c" /> | ||
6 | <ClCompile Include="src\except.c" /> | ||
7 | <ClCompile Include="src\inet.c" /> | ||
8 | <ClCompile Include="src\io.c" /> | ||
9 | <ClCompile Include="src\luasocket.c" /> | ||
10 | <ClCompile Include="src\options.c" /> | ||
11 | <ClCompile Include="src\select.c" /> | ||
12 | <ClCompile Include="src\tcp.c" /> | ||
13 | <ClCompile Include="src\timeout.c" /> | ||
14 | <ClCompile Include="src\udp.c" /> | ||
15 | <ClCompile Include="src\wsocket.c" /> | ||
16 | </ItemGroup> | ||
17 | <ItemGroup> | ||
18 | <CustomBuild Include="src\ltn12.lua"> | ||
19 | <Filter>cdir</Filter> | ||
20 | </CustomBuild> | ||
21 | <CustomBuild Include="src\socket.lua"> | ||
22 | <Filter>cdir</Filter> | ||
23 | </CustomBuild> | ||
24 | <CustomBuild Include="src\ftp.lua"> | ||
25 | <Filter>ldir</Filter> | ||
26 | </CustomBuild> | ||
27 | <CustomBuild Include="src\headers.lua"> | ||
28 | <Filter>ldir</Filter> | ||
29 | </CustomBuild> | ||
30 | <CustomBuild Include="src\http.lua"> | ||
31 | <Filter>ldir</Filter> | ||
32 | </CustomBuild> | ||
33 | <CustomBuild Include="src\smtp.lua"> | ||
34 | <Filter>ldir</Filter> | ||
35 | </CustomBuild> | ||
36 | <CustomBuild Include="src\tp.lua"> | ||
37 | <Filter>ldir</Filter> | ||
38 | </CustomBuild> | ||
39 | <CustomBuild Include="src\url.lua"> | ||
40 | <Filter>ldir</Filter> | ||
41 | </CustomBuild> | ||
42 | </ItemGroup> | ||
43 | <ItemGroup> | ||
44 | <Filter Include="cdir"> | ||
45 | <UniqueIdentifier>{b053460d-5439-4e3a-a2eb-c31a95b5691f}</UniqueIdentifier> | ||
46 | </Filter> | ||
47 | <Filter Include="ldir"> | ||
48 | <UniqueIdentifier>{b301b82c-37cb-4e05-9333-194e92ed7a62}</UniqueIdentifier> | ||
49 | </Filter> | ||
50 | </ItemGroup> | ||
51 | </Project> \ No newline at end of file | ||
@@ -79,24 +79,22 @@ static int inet_global_tohostname(lua_State *L) { | |||
79 | } | 79 | } |
80 | 80 | ||
81 | static int inet_global_getnameinfo(lua_State *L) { | 81 | static int inet_global_getnameinfo(lua_State *L) { |
82 | char hbuf[NI_MAXHOST]; | ||
83 | char sbuf[NI_MAXSERV]; | ||
82 | int i, ret; | 84 | int i, ret; |
83 | char host[1024]; | ||
84 | char serv[32]; | ||
85 | struct addrinfo hints; | 85 | struct addrinfo hints; |
86 | struct addrinfo *resolved, *iter; | 86 | struct addrinfo *resolved, *iter; |
87 | const char *node = luaL_optstring(L, 1, NULL); | 87 | const char *host = luaL_optstring(L, 1, NULL); |
88 | const char *service = luaL_optstring(L, 2, NULL); | 88 | const char *serv = luaL_optstring(L, 2, NULL); |
89 | 89 | ||
90 | if (!(node || service)) | 90 | if (!(host || serv)) |
91 | luaL_error(L, "You have to specify a hostname, a service, or both"); | 91 | luaL_error(L, "host and serv cannot be both nil"); |
92 | 92 | ||
93 | memset(&hints, 0, sizeof(hints)); | 93 | memset(&hints, 0, sizeof(hints)); |
94 | hints.ai_socktype = SOCK_STREAM; | 94 | hints.ai_socktype = SOCK_STREAM; |
95 | hints.ai_family = PF_UNSPEC; | 95 | hints.ai_family = PF_UNSPEC; |
96 | 96 | ||
97 | /* getaddrinfo must get a node and a service argument */ | 97 | ret = getaddrinfo(host, serv, &hints, &resolved); |
98 | ret = getaddrinfo(node ? node : "127.0.0.1", service ? service : "7", | ||
99 | &hints, &resolved); | ||
100 | if (ret != 0) { | 98 | if (ret != 0) { |
101 | lua_pushnil(L); | 99 | lua_pushnil(L); |
102 | lua_pushstring(L, socket_gaistrerror(ret)); | 100 | lua_pushstring(L, socket_gaistrerror(ret)); |
@@ -105,19 +103,19 @@ static int inet_global_getnameinfo(lua_State *L) { | |||
105 | 103 | ||
106 | lua_newtable(L); | 104 | lua_newtable(L); |
107 | for (i = 1, iter = resolved; iter; i++, iter = iter->ai_next) { | 105 | for (i = 1, iter = resolved; iter; i++, iter = iter->ai_next) { |
108 | getnameinfo(iter->ai_addr, (socklen_t) iter->ai_addrlen, host, | 106 | getnameinfo(iter->ai_addr, (socklen_t) iter->ai_addrlen, |
109 | node ? (socklen_t) sizeof(host) : 0, serv, service ? (socklen_t) sizeof(serv) : 0, 0); | 107 | hbuf, host? (socklen_t) sizeof(hbuf): 0, |
110 | 108 | sbuf, serv? (socklen_t) sizeof(sbuf): 0, 0); | |
111 | if (node) { | 109 | if (host) { |
112 | lua_pushnumber(L, i); | 110 | lua_pushnumber(L, i); |
113 | lua_pushstring(L, host); | 111 | lua_pushstring(L, hbuf); |
114 | lua_settable(L, -3); | 112 | lua_settable(L, -3); |
115 | } | 113 | } |
116 | } | 114 | } |
117 | freeaddrinfo(resolved); | 115 | freeaddrinfo(resolved); |
118 | 116 | ||
119 | if (service) { | 117 | if (serv) { |
120 | lua_pushstring(L, serv); | 118 | lua_pushstring(L, sbuf); |
121 | return 2; | 119 | return 2; |
122 | } else { | 120 | } else { |
123 | return 1; | 121 | return 1; |
@@ -176,20 +174,10 @@ static int inet_global_getaddrinfo(lua_State *L) | |||
176 | } | 174 | } |
177 | lua_newtable(L); | 175 | lua_newtable(L); |
178 | for (iterator = resolved; iterator; iterator = iterator->ai_next) { | 176 | for (iterator = resolved; iterator; iterator = iterator->ai_next) { |
179 | char hbuf[NI_MAXHOST] | 177 | char hbuf[NI_MAXHOST]; |
180 | #ifndef _WINDOWS | 178 | ret = getnameinfo(iterator->ai_addr, (socklen_t) iterator->ai_addrlen, |
181 | ,sbuf[NI_MAXSERV] | 179 | hbuf, (socklen_t) sizeof(hbuf), NULL, 0, NI_NUMERICHOST); |
182 | #endif | 180 | if (ret){ |
183 | ; | ||
184 | ret = getnameinfo(iterator->ai_addr, (socklen_t) iterator->ai_addrlen, hbuf, | ||
185 | (socklen_t) sizeof(hbuf), | ||
186 | #ifdef _WINDOWS | ||
187 | NULL, 0, | ||
188 | #else | ||
189 | sbuf, 0, | ||
190 | #endif | ||
191 | NI_NUMERICHOST); | ||
192 | if(ret){ | ||
193 | lua_pushnil(L); | 181 | lua_pushnil(L); |
194 | lua_pushstring(L, socket_gaistrerror(ret)); | 182 | lua_pushstring(L, socket_gaistrerror(ret)); |
195 | return 2; | 183 | return 2; |
@@ -218,7 +206,6 @@ static int inet_global_getaddrinfo(lua_State *L) | |||
218 | return 1; | 206 | return 1; |
219 | } | 207 | } |
220 | 208 | ||
221 | |||
222 | /*-------------------------------------------------------------------------*\ | 209 | /*-------------------------------------------------------------------------*\ |
223 | * Gets the host name | 210 | * Gets the host name |
224 | \*-------------------------------------------------------------------------*/ | 211 | \*-------------------------------------------------------------------------*/ |
@@ -237,7 +224,6 @@ static int inet_global_gethostname(lua_State *L) | |||
237 | } | 224 | } |
238 | 225 | ||
239 | 226 | ||
240 | |||
241 | /*=========================================================================*\ | 227 | /*=========================================================================*\ |
242 | * Lua methods | 228 | * Lua methods |
243 | \*=========================================================================*/ | 229 | \*=========================================================================*/ |
@@ -520,7 +506,7 @@ const char *inet_trybind(p_socket ps, const char *address, const char *serv, | |||
520 | * Some systems do not provide this so that we provide our own. It's not | 506 | * Some systems do not provide this so that we provide our own. It's not |
521 | * marvelously fast, but it works just fine. | 507 | * marvelously fast, but it works just fine. |
522 | \*-------------------------------------------------------------------------*/ | 508 | \*-------------------------------------------------------------------------*/ |
523 | #ifdef INET_ATON | 509 | #ifdef LUASOCKET_INET_ATON |
524 | int inet_aton(const char *cp, struct in_addr *inp) | 510 | int inet_aton(const char *cp, struct in_addr *inp) |
525 | { | 511 | { |
526 | unsigned int a = 0, b = 0, c = 0, d = 0; | 512 | unsigned int a = 0, b = 0, c = 0, d = 0; |
@@ -547,7 +533,7 @@ int inet_aton(const char *cp, struct in_addr *inp) | |||
547 | * http://mingw-users.1079350.n2.nabble.com/IPv6-getaddrinfo-amp-inet-ntop-td5891996.html | 533 | * http://mingw-users.1079350.n2.nabble.com/IPv6-getaddrinfo-amp-inet-ntop-td5891996.html |
548 | \*-------------------------------------------------------------------------*/ | 534 | \*-------------------------------------------------------------------------*/ |
549 | 535 | ||
550 | #ifdef INET_PTON | 536 | #ifdef LUASOCKET_INET_PTON |
551 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | 537 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) |
552 | { | 538 | { |
553 | if (af == AF_INET) { | 539 | if (af == AF_INET) { |
@@ -572,19 +558,23 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) | |||
572 | 558 | ||
573 | int inet_pton(int af, const char *src, void *dst) | 559 | int inet_pton(int af, const char *src, void *dst) |
574 | { | 560 | { |
575 | struct addrinfo hints, *res, *ressave; | 561 | struct addrinfo hints, *res; |
562 | int ret = 1; | ||
576 | memset(&hints, 0, sizeof(struct addrinfo)); | 563 | memset(&hints, 0, sizeof(struct addrinfo)); |
577 | hints.ai_family = af; | 564 | hints.ai_family = af; |
578 | if (getaddrinfo(src, NULL, &hints, &res) != 0) { | 565 | hints.ai_flags = AI_NUMERICHOST; |
579 | return -1; | 566 | if (getaddrinfo(src, NULL, &hints, &res) != 0) return -1; |
580 | } | 567 | if (af == AF_INET) { |
581 | ressave = res; | 568 | struct sockaddr_in *in = (struct sockaddr_in *) res->ai_addr; |
582 | while (res) { | 569 | memcpy(dst, &in->sin_addr, sizeof(in->sin_addr)); |
583 | memcpy(dst, res->ai_addr, res->ai_addrlen); | 570 | } else if (af == AF_INET6) { |
584 | res = res->ai_next; | 571 | struct sockaddr_in6 *in = (struct sockaddr_in6 *) res->ai_addr; |
572 | memcpy(dst, &in->sin6_addr, sizeof(in->sin6_addr)); | ||
573 | } else { | ||
574 | ret = -1; | ||
585 | } | 575 | } |
586 | freeaddrinfo(ressave); | 576 | freeaddrinfo(res); |
587 | return 0; | 577 | return ret; |
588 | } | 578 | } |
589 | 579 | ||
590 | #endif | 580 | #endif |
@@ -19,8 +19,7 @@ | |||
19 | #include "timeout.h" | 19 | #include "timeout.h" |
20 | 20 | ||
21 | #ifdef _WIN32 | 21 | #ifdef _WIN32 |
22 | #define INET_ATON | 22 | #define LUASOCKET_INET_ATON |
23 | #define INET_PTON | ||
24 | #endif | 23 | #endif |
25 | 24 | ||
26 | int inet_open(lua_State *L); | 25 | int inet_open(lua_State *L); |
@@ -39,11 +38,11 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family); | |||
39 | int inet_optfamily(lua_State* L, int narg, const char* def); | 38 | int inet_optfamily(lua_State* L, int narg, const char* def); |
40 | int inet_optsocktype(lua_State* L, int narg, const char* def); | 39 | int inet_optsocktype(lua_State* L, int narg, const char* def); |
41 | 40 | ||
42 | #ifdef INET_ATON | 41 | #ifdef LUASOCKET_INET_ATON |
43 | int inet_aton(const char *cp, struct in_addr *inp); | 42 | int inet_aton(const char *cp, struct in_addr *inp); |
44 | #endif | 43 | #endif |
45 | 44 | ||
46 | #ifdef INET_PTON | 45 | #ifdef LUASOCKET_INET_PTON |
47 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); | 46 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); |
48 | int inet_pton(int af, const char *src, void *dst); | 47 | int inet_pton(int af, const char *src, void *dst); |
49 | #endif | 48 | #endif |
@@ -22,7 +22,7 @@ enum { | |||
22 | IO_DONE = 0, /* operation completed successfully */ | 22 | IO_DONE = 0, /* operation completed successfully */ |
23 | IO_TIMEOUT = -1, /* operation timed out */ | 23 | IO_TIMEOUT = -1, /* operation timed out */ |
24 | IO_CLOSED = -2, /* the connection has been closed */ | 24 | IO_CLOSED = -2, /* the connection has been closed */ |
25 | IO_UNKNOWN = -3 | 25 | IO_UNKNOWN = -3 |
26 | }; | 26 | }; |
27 | 27 | ||
28 | /* interface to error message function */ | 28 | /* interface to error message function */ |
diff --git a/src/makefile b/src/makefile index fbb26a0..94a2f9f 100644 --- a/src/makefile +++ b/src/makefile | |||
@@ -63,12 +63,13 @@ LDIR_mingw?=lua/$(LUAV)/lua | |||
63 | # LUAINC_win32: | 63 | # LUAINC_win32: |
64 | # LUALIB_win32: | 64 | # LUALIB_win32: |
65 | # where lua headers and libraries are found for win32 builds | 65 | # where lua headers and libraries are found for win32 builds |
66 | LUAINC_win32?="../../lua-5.1.3/src" | 66 | LUAINC_win32_base?= |
67 | LUALIB_win32?=/LIBPATH:"../../lua-5.1.3" lua$(LUAV).lib | 67 | LUAINC_win32?=$(LUAINC_win32_base)/lua/$(LUAV) |
68 | 68 | PLATFORM_win32?=Release | |
69 | LUAPREFIX_win32?= | 69 | LUAPREFIX_win32?= |
70 | CDIR_win32?=lua/$(LUAV) | 70 | CDIR_win32?=lua/$(LUAV)/$(PLATFORM_win32) |
71 | LDIR_win32?=lua/$(LUAV)/lua | 71 | LDIR_win32?=lua/$(LUAV)/$(PLATFORM_win32)/lua |
72 | LUALIB_win32?=$(LUAPREFIX_win32)/lua/$(LUAV)/$(PLATFORM_win32) | ||
72 | 73 | ||
73 | # prefix: /usr/local /usr /opt/local /sw | 74 | # prefix: /usr/local /usr /opt/local /sw |
74 | # the top of the default install tree | 75 | # the top of the default install tree |
@@ -154,12 +155,12 @@ SOCKET_linux=usocket.o | |||
154 | SO_mingw=dll | 155 | SO_mingw=dll |
155 | O_mingw=o | 156 | O_mingw=o |
156 | CC_mingw=gcc | 157 | CC_mingw=gcc |
157 | DEF_mingw= -DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE -DWINVER=0x0501 \ | 158 | DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE \ |
158 | -DLUASOCKET_API='__declspec(dllexport)' \ | 159 | -DWINVER=0x0501 -DLUASOCKET_API='__declspec(dllexport)' \ |
159 | -DMIME_API='__declspec(dllexport)' | 160 | -DMIME_API='__declspec(dllexport)' |
160 | CFLAGS_mingw= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ | 161 | CFLAGS_mingw= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ |
161 | -fvisibility=hidden | 162 | -fvisibility=hidden |
162 | LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lwsock32 -lws2_32 -o | 163 | LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o |
163 | LD_mingw=gcc | 164 | LD_mingw=gcc |
164 | SOCKET_mingw=wsocket.o | 165 | SOCKET_mingw=wsocket.o |
165 | 166 | ||
@@ -170,23 +171,25 @@ SOCKET_mingw=wsocket.o | |||
170 | SO_win32=dll | 171 | SO_win32=dll |
171 | O_win32=obj | 172 | O_win32=obj |
172 | CC_win32=cl | 173 | CC_win32=cl |
173 | DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ | 174 | DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \ |
174 | /D "LUASOCKET_API=__declspec(dllexport)" /D "_CRT_SECURE_NO_WARNINGS" \ | 175 | //D "LUASOCKET_API=__declspec(dllexport)" //D "_CRT_SECURE_NO_WARNINGS" \ |
175 | /D "_WINDLL" /D "LUA_COMPAT_MODULE" /D "MIME_API=__declspec(dllexport)" \ | 176 | //D "_WINDLL" //D "LUA_COMPAT_MODULE" \ |
176 | /D "LUASOCKET_$(DEBUG)" | 177 | //D "MIME_API=__declspec(dllexport)" \ |
177 | CFLAGS_win32=/I "$(LUAINC)" $(DEF) /O2 /Ot /MD /W3 /nologo | 178 | //D "LUASOCKET_$(DEBUG)" |
178 | LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ | 179 | CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo |
179 | /MANIFEST /MANIFESTFILE:"intermediate.manifest" \ | 180 | LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \ |
180 | /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ | 181 | //MANIFEST //MANIFESTFILE:"intermediate.manifest" \ |
181 | /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /DYNAMICBASE:NO \ | 182 | //MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ |
182 | /MACHINE:X86 $(LUALIB) ws2_32.lib /OUT: | 183 | //SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \ |
184 | //MACHINE:X86 /LIBPATH:"$(shell cmd //c echo $(LUALIB))" \ | ||
185 | lua$(subst .,,$(LUAV)).lib ws2_32.lib //OUT: | ||
183 | LD_win32=cl | 186 | LD_win32=cl |
184 | SOCKET_win32=wsocket.obj | 187 | SOCKET_win32=wsocket.obj |
185 | 188 | ||
186 | .SUFFIXES: .obj | 189 | .SUFFIXES: .obj |
187 | 190 | ||
188 | .c.obj: | 191 | .c.obj: |
189 | $(CC) $(CFLAGS) /Fo"$@" /c $< | 192 | $(CC) $(CFLAGS) //Fo"$@" //c $< |
190 | 193 | ||
191 | #------ | 194 | #------ |
192 | # Output file names | 195 | # Output file names |
@@ -155,31 +155,31 @@ static int meth_sendto(lua_State *L) { | |||
155 | p_timeout tm = &udp->tm; | 155 | p_timeout tm = &udp->tm; |
156 | int err; | 156 | int err; |
157 | switch (udp->family) { | 157 | switch (udp->family) { |
158 | case PF_INET: { | 158 | case PF_INET: { |
159 | struct sockaddr_in addr; | 159 | struct sockaddr_in addr; |
160 | memset(&addr, 0, sizeof(addr)); | 160 | memset(&addr, 0, sizeof(addr)); |
161 | if (!inet_pton(AF_INET, ip, &addr.sin_addr)) | 161 | if (inet_pton(AF_INET, ip, &addr.sin_addr) != 1) |
162 | luaL_argerror(L, 3, "invalid ip address"); | 162 | luaL_argerror(L, 3, "invalid ip address"); |
163 | addr.sin_family = AF_INET; | 163 | addr.sin_family = AF_INET; |
164 | addr.sin_port = htons(port); | 164 | addr.sin_port = htons(port); |
165 | timeout_markstart(tm); | 165 | timeout_markstart(tm); |
166 | err = socket_sendto(&udp->sock, data, count, &sent, | 166 | err = socket_sendto(&udp->sock, data, count, &sent, |
167 | (SA *) &addr, sizeof(addr), tm); | 167 | (SA *) &addr, sizeof(addr), tm); |
168 | break; | 168 | break; |
169 | } | 169 | } |
170 | case PF_INET6: { | 170 | case PF_INET6: { |
171 | struct sockaddr_in6 addr; | 171 | struct sockaddr_in6 addr; |
172 | memset(&addr, 0, sizeof(addr)); | 172 | memset(&addr, 0, sizeof(addr)); |
173 | if (!inet_pton(AF_INET6, ip, &addr.sin6_addr)) | 173 | if (inet_pton(AF_INET6, ip, &addr.sin6_addr) != 1) |
174 | luaL_argerror(L, 3, "invalid ip address"); | 174 | luaL_argerror(L, 3, "invalid ip address"); |
175 | addr.sin6_family = AF_INET6; | 175 | addr.sin6_family = AF_INET6; |
176 | addr.sin6_port = htons(port); | 176 | addr.sin6_port = htons(port); |
177 | timeout_markstart(tm); | 177 | timeout_markstart(tm); |
178 | err = socket_sendto(&udp->sock, data, count, &sent, | 178 | err = socket_sendto(&udp->sock, data, count, &sent, |
179 | (SA *) &addr, sizeof(addr), tm); | 179 | (SA *) &addr, sizeof(addr), tm); |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | default: | 182 | default: |
183 | lua_pushnil(L); | 183 | lua_pushnil(L); |
184 | lua_pushfstring(L, "unknown family %d", udp->family); | 184 | lua_pushfstring(L, "unknown family %d", udp->family); |
185 | return 2; | 185 | return 2; |
@@ -229,38 +229,40 @@ static int meth_receivefrom(lua_State *L) { | |||
229 | timeout_markstart(tm); | 229 | timeout_markstart(tm); |
230 | count = MIN(count, sizeof(buffer)); | 230 | count = MIN(count, sizeof(buffer)); |
231 | switch (udp->family) { | 231 | switch (udp->family) { |
232 | case PF_INET: { | 232 | case PF_INET: { |
233 | struct sockaddr_in addr; | 233 | struct sockaddr_in addr; |
234 | socklen_t addr_len = sizeof(addr); | 234 | socklen_t addr_len = sizeof(addr); |
235 | err = socket_recvfrom(&udp->sock, buffer, count, &got, | 235 | err = socket_recvfrom(&udp->sock, buffer, count, &got, |
236 | (SA *) &addr, &addr_len, tm); | 236 | (SA *) &addr, &addr_len, tm); |
237 | /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ | 237 | /* Unlike TCP, recv() of zero is not closed, |
238 | if (err == IO_CLOSED) | 238 | * but a zero-length packet. */ |
239 | err = IO_DONE; | 239 | if (err == IO_CLOSED) |
240 | if (err == IO_DONE) { | 240 | err = IO_DONE; |
241 | char addrstr[INET_ADDRSTRLEN]; | 241 | if (err == IO_DONE) { |
242 | lua_pushlstring(L, buffer, got); | 242 | char addrstr[INET_ADDRSTRLEN]; |
243 | if (!inet_ntop(AF_INET, &addr.sin_addr, | 243 | lua_pushlstring(L, buffer, got); |
244 | addrstr, sizeof(addrstr))) { | 244 | if (!inet_ntop(AF_INET, &addr.sin_addr, |
245 | lua_pushnil(L); | 245 | addrstr, sizeof(addrstr))) { |
246 | lua_pushstring(L, "invalid source address"); | 246 | lua_pushnil(L); |
247 | return 2; | 247 | lua_pushstring(L, "invalid source address"); |
248 | } | 248 | return 2; |
249 | lua_pushstring(L, addrstr); | 249 | } |
250 | lua_pushnumber(L, ntohs(addr.sin_port)); | 250 | lua_pushstring(L, addrstr); |
251 | return 3; | 251 | lua_pushnumber(L, ntohs(addr.sin_port)); |
252 | } | 252 | return 3; |
253 | break; | 253 | } |
254 | } | 254 | break; |
255 | case PF_INET6: { | 255 | } |
256 | struct sockaddr_in6 addr; | 256 | case PF_INET6: { |
257 | socklen_t addr_len = sizeof(addr); | 257 | struct sockaddr_in6 addr; |
258 | err = socket_recvfrom(&udp->sock, buffer, count, &got, | 258 | socklen_t addr_len = sizeof(addr); |
259 | (SA *) &addr, &addr_len, tm); | 259 | err = socket_recvfrom(&udp->sock, buffer, count, &got, |
260 | /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ | 260 | (SA *) &addr, &addr_len, tm); |
261 | if (err == IO_CLOSED) | 261 | /* Unlike TCP, recv() of zero is not closed, |
262 | * but a zero-length packet. */ | ||
263 | if (err == IO_CLOSED) | ||
262 | err = IO_DONE; | 264 | err = IO_DONE; |
263 | if (err == IO_DONE) { | 265 | if (err == IO_DONE) { |
264 | char addrstr[INET6_ADDRSTRLEN]; | 266 | char addrstr[INET6_ADDRSTRLEN]; |
265 | lua_pushlstring(L, buffer, got); | 267 | lua_pushlstring(L, buffer, got); |
266 | if (!inet_ntop(AF_INET6, &addr.sin6_addr, | 268 | if (!inet_ntop(AF_INET6, &addr.sin6_addr, |
@@ -272,9 +274,9 @@ static int meth_receivefrom(lua_State *L) { | |||
272 | lua_pushstring(L, addrstr); | 274 | lua_pushstring(L, addrstr); |
273 | lua_pushnumber(L, ntohs(addr.sin6_port)); | 275 | lua_pushnumber(L, ntohs(addr.sin6_port)); |
274 | return 3; | 276 | return 3; |
275 | } | 277 | } |
276 | break; | 278 | break; |
277 | } | 279 | } |
278 | default: | 280 | default: |
279 | lua_pushnil(L); | 281 | lua_pushnil(L); |
280 | lua_pushfstring(L, "unknown family %d", udp->family); | 282 | lua_pushfstring(L, "unknown family %d", udp->family); |
@@ -413,7 +415,7 @@ static int meth_setsockname(lua_State *L) { | |||
413 | const char *address = luaL_checkstring(L, 2); | 415 | const char *address = luaL_checkstring(L, 2); |
414 | const char *port = luaL_checkstring(L, 3); | 416 | const char *port = luaL_checkstring(L, 3); |
415 | const char *err; | 417 | const char *err; |
416 | struct addrinfo bindhints; | 418 | struct addrinfo bindhints; |
417 | memset(&bindhints, 0, sizeof(bindhints)); | 419 | memset(&bindhints, 0, sizeof(bindhints)); |
418 | bindhints.ai_socktype = SOCK_DGRAM; | 420 | bindhints.ai_socktype = SOCK_DGRAM; |
419 | bindhints.ai_family = udp->family; | 421 | bindhints.ai_family = udp->family; |
@@ -461,9 +463,9 @@ static int udp_create(lua_State *L, int family) { | |||
461 | } | 463 | } |
462 | 464 | ||
463 | static int global_create(lua_State *L) { | 465 | static int global_create(lua_State *L) { |
464 | return udp_create(L, AF_INET); | 466 | return udp_create(L, AF_INET); |
465 | } | 467 | } |
466 | 468 | ||
467 | static int global_create6(lua_State *L) { | 469 | static int global_create6(lua_State *L) { |
468 | return udp_create(L, AF_INET6); | 470 | return udp_create(L, AF_INET6); |
469 | } | 471 | } |
diff --git a/src/wsocket.c b/src/wsocket.c index 65f76bc..b4a4384 100644 --- a/src/wsocket.c +++ b/src/wsocket.c | |||
@@ -238,8 +238,10 @@ int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, | |||
238 | /*-------------------------------------------------------------------------*\ | 238 | /*-------------------------------------------------------------------------*\ |
239 | * Receive with timeout | 239 | * Receive with timeout |
240 | \*-------------------------------------------------------------------------*/ | 240 | \*-------------------------------------------------------------------------*/ |
241 | int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) { | 241 | int socket_recv(p_socket ps, char *data, size_t count, size_t *got, |
242 | int err; | 242 | p_timeout tm) |
243 | { | ||
244 | int err, prev = IO_DONE; | ||
243 | *got = 0; | 245 | *got = 0; |
244 | if (*ps == SOCKET_INVALID) return IO_CLOSED; | 246 | if (*ps == SOCKET_INVALID) return IO_CLOSED; |
245 | for ( ;; ) { | 247 | for ( ;; ) { |
@@ -250,7 +252,14 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm | |||
250 | } | 252 | } |
251 | if (taken == 0) return IO_CLOSED; | 253 | if (taken == 0) return IO_CLOSED; |
252 | err = WSAGetLastError(); | 254 | err = WSAGetLastError(); |
253 | if (err != WSAEWOULDBLOCK) return err; | 255 | /* On UDP, a connreset simply means the previous send failed. |
256 | * So we try again. | ||
257 | * On TCP, it means our socket is now useless, so the error passes. | ||
258 | * (We will loop again, exiting because the same error will happen) */ | ||
259 | if (err != WSAEWOULDBLOCK) { | ||
260 | if (err != WSAECONNRESET || prev == WSAECONNRESET) return err; | ||
261 | prev = err; | ||
262 | } | ||
254 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; | 263 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; |
255 | } | 264 | } |
256 | } | 265 | } |
@@ -259,8 +268,9 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm | |||
259 | * Recvfrom with timeout | 268 | * Recvfrom with timeout |
260 | \*-------------------------------------------------------------------------*/ | 269 | \*-------------------------------------------------------------------------*/ |
261 | int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, | 270 | int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, |
262 | SA *addr, socklen_t *len, p_timeout tm) { | 271 | SA *addr, socklen_t *len, p_timeout tm) |
263 | int err; | 272 | { |
273 | int err, prev = IO_DONE; | ||
264 | *got = 0; | 274 | *got = 0; |
265 | if (*ps == SOCKET_INVALID) return IO_CLOSED; | 275 | if (*ps == SOCKET_INVALID) return IO_CLOSED; |
266 | for ( ;; ) { | 276 | for ( ;; ) { |
@@ -271,7 +281,14 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, | |||
271 | } | 281 | } |
272 | if (taken == 0) return IO_CLOSED; | 282 | if (taken == 0) return IO_CLOSED; |
273 | err = WSAGetLastError(); | 283 | err = WSAGetLastError(); |
274 | if (err != WSAEWOULDBLOCK) return err; | 284 | /* On UDP, a connreset simply means the previous send failed. |
285 | * So we try again. | ||
286 | * On TCP, it means our socket is now useless, so the error passes. | ||
287 | * (We will loop again, exiting because the same error will happen) */ | ||
288 | if (err != WSAEWOULDBLOCK) { | ||
289 | if (err != WSAECONNRESET || prev == WSAECONNRESET) return err; | ||
290 | prev = err; | ||
291 | } | ||
275 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; | 292 | if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; |
276 | } | 293 | } |
277 | } | 294 | } |