Browse Source

fix getClient method does not return automatically if a server is closed with the trenne method

Kolja Strohm 1 year ago
parent
commit
7966f9f393
3 changed files with 37 additions and 5 deletions
  1. 9 3
      Network Linux.vcxproj
  2. 1 1
      Network/Network.vcxproj
  3. 27 1
      Network/Server.cpp

+ 9 - 3
Network Linux.vcxproj

@@ -25,6 +25,7 @@
     <UseDebugLibraries>true</UseDebugLibraries>
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <RemoteRootDir>/home/kolja/projects</RemoteRootDir>
+    <RemoteProjectRelDir>/home/kolja/projects/Network/debug/</RemoteProjectRelDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
     <UseDebugLibraries>false</UseDebugLibraries>
@@ -41,9 +42,12 @@
     <TargetExt>.so</TargetExt>
     <RemoteProjectDir>$(RemoteRootDir)/Network/debug</RemoteProjectDir>
     <IncludePath>..\Framework;$(IncludePath);$(ISenseIncludePath);../../Framework/release</IncludePath>
-    <OutDir>$(RemoteRootDir)/Network/debug/</OutDir>
-    <IntDir>$(RemoteRootDir)/Network/debug/</IntDir>
+    <OutDir>/home/kolja/projects/Network/debug/</OutDir>
+    <IntDir>/home/kolja/projects/Network/debug/</IntDir>
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
+    <RemoteIntRelDir>/home/kolja/projects/Network/debug/</RemoteIntRelDir>
+    <RemoteOutRelDir>/home/kolja/projects/Network/debug/</RemoteOutRelDir>
+    <RemoteDeployDir>/home/kolja/projects/Network/debug/</RemoteDeployDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <RemoteProjectDir>$(RemoteRootDir)/Network/release</RemoteProjectDir>
@@ -70,6 +74,7 @@
     <Link />
     <ClCompile>
       <AdditionalOptions>-fPIC %(AdditionalOptions)</AdditionalOptions>
+      <AdditionalIncludeDirectories>$(IncludePath);$(ISenseIncludePath);../../Framework/release</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <ForceUndefineSymbolReferences>
@@ -82,7 +87,8 @@
     <Link />
     <ClCompile>
       <AdditionalOptions>-fPIC %(AdditionalOptions)</AdditionalOptions>
-      <AdditionalIncludeDirectories>%(ClCompile.AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(IncludePath);$(ISenseIncludePath);../../Framework/debug</AdditionalIncludeDirectories>
+      <ObjectFileName>%(filename).o</ObjectFileName>
     </ClCompile>
     <Link>
       <ForceUndefineSymbolReferences>

+ 1 - 1
Network/Network.vcxproj

@@ -22,7 +22,7 @@
     <ProjectGuid>{E52010A0-0060-42AA-9769-AAF6488F8C1C}</ProjectGuid>
     <Keyword>Win32Proj</Keyword>
     <RootNamespace>Network</RootNamespace>
-    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

+ 27 - 1
Network/Server.cpp

@@ -51,7 +51,20 @@ SKlient* Server::getKlient() // nimmt Klient an
 	if (!sock)
 		return 0;
 	sockaddr_in client;
-	int len = sizeof(addresse);
+    int len = sizeof(addresse);
+    fd_set set;
+    FD_ZERO(&set);   /* clear the set */
+    FD_SET(sock, &set); /* add our file descriptor to the set */
+    int rv = 0;
+    struct timeval timeout;
+    timeout.tv_sec = 10;
+    timeout.tv_usec = 0;
+    while (rv == 0 && sock)
+    {
+        rv = select((int)sock + 1, &set, NULL, NULL, &timeout);
+        if (rv == -1) return 0;
+    }
+    if (!sock) return 0;
 #ifdef WIN32
 	SOCKET cls = accept(sock, (sockaddr*)&client, &len); // Klient empfangen
 	if (cls == INVALID_SOCKET)
@@ -416,6 +429,19 @@ SSLSKlient* SSLServer::getKlient()
 		return 0;
 	int len = sizeof(addr);
 	struct sockaddr_in addr;
+    fd_set set;
+    FD_ZERO(&set);   /* clear the set */
+    FD_SET(s, &set); /* add our file descriptor to the set */
+    int rv = 0;
+    struct timeval timeout;
+    timeout.tv_sec = 10;
+    timeout.tv_usec = 0;
+    while (rv == 0 && s)
+    {
+        rv = select((int)s + 1, &set, NULL, NULL, &timeout);
+        if (rv == -1) return 0;
+    }
+    if (!s) return 0;
 #ifdef WIN32
 	SOCKET client = accept(s, (struct sockaddr*)&addr, &len);
 	if (client == INVALID_SOCKET)