Windows 10: Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the...

Discus and support Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the... in Windows 10 Network and Sharing to solve the problem; I am not sure if anyone had encounter this but this wasn't an issue in the previous version of Windows. System Info: Windows Server 2019 V10.0.17763,... Discussion in 'Windows 10 Network and Sharing' started by Simon Guo, Mar 29, 2019.

  1. Simon Guo Win User

    Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the...


    I am not sure if anyone had encounter this but this wasn't an issue in the previous version of Windows.


    System Info: Windows Server 2019 V10.0.17763, Visual Studio 2017 Professional, Microsoft Visual C++ 2017 Redistributable



    Issue: Socket receive timeout is 1000 times faster than the value was defined in the timeval struct (in WinSock2.h). The issue does not appear on Windows Server 2012 and Server 2016 with VS2017 installed.



    Work Around: Passing integer value (in millisecond) instead of timeval struct on the setsockopt() call seems not a problem. However, it will require code change in my software.




    The following code can reproduce this issue on Windows Server 2019. You will need a socket client to connect to the opening port.

    The issue can be also seen by calling getsockopt() for retrieving timeout value. The tv_sec field of timeval structure is more like in millisecond instead of second.



    #undef UNICODE


    #define WIN32_LEAN_AND_MEAN


    #include <windows.h>
    #include <winsock2.h>
    #include <ws2tcpip.h>
    #include <stdlib.h>
    #include <stdio.h>


    // Need to link with Ws2_32.lib
    #pragma comment (lib, "Ws2_32.lib")
    // #pragma comment (lib, "Mswsock.lib")


    #define DEFAULT_BUFLEN 512
    #define DEFAULT_PORT "27015"


    int __cdecl main(void)
    {
    WSADATA wsaData;
    int iResult;


    SOCKET ListenSocket = INVALID_SOCKET;
    SOCKET ClientSocket = INVALID_SOCKET;


    struct addrinfo *result = NULL;
    struct addrinfo hints;


    int iSendResult;
    char recvbuf[DEFAULT_BUFLEN];
    int recvbuflen = DEFAULT_BUFLEN;


    // Initialize Winsock
    iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
    if (iResult != 0) {
    printf("WSAStartup failed with error: %d\n", iResult);
    return 1;
    }


    ZeroMemory(&hints, sizeof(hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;
    hints.ai_flags = AI_PASSIVE;


    // Resolve the server address and port
    iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
    if (iResult != 0) {
    printf("getaddrinfo failed with error: %d\n", iResult);
    WSACleanup();
    return 1;
    }


    // Create a SOCKET for connecting to server
    ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
    if (ListenSocket == INVALID_SOCKET) {
    printf("socket failed with error: %ld\n", WSAGetLastError());
    freeaddrinfo(result);
    WSACleanup();
    return 1;
    }


    // Setup the TCP listening socket
    iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen);
    if (iResult == SOCKET_ERROR) {
    printf("bind failed with error: %d\n", WSAGetLastError());
    freeaddrinfo(result);
    closesocket(ListenSocket);
    WSACleanup();
    return 1;
    }


    freeaddrinfo(result);


    iResult = listen(ListenSocket, SOMAXCONN);
    if (iResult == SOCKET_ERROR) {
    printf("listen failed with error: %d\n", WSAGetLastError());
    closesocket(ListenSocket);
    WSACleanup();
    return 1;
    }


    // Accept a client socket
    ClientSocket = accept(ListenSocket, NULL, NULL);
    if (ClientSocket == INVALID_SOCKET) {
    printf("accept failed with error: %d\n", WSAGetLastError());
    closesocket(ListenSocket);
    WSACleanup();
    return 1;
    }


    // No longer need server socket
    closesocket(ListenSocket);


    // Receive until the peer shuts down the connection
    do {


    struct timeval tv;
    tv.tv_sec = 5;
    tv.tv_usec = 0;
    int timeoutVal = 0;
    int timeoutValSizeInInt = sizeof(int);
    int timeoutValSizeInTimeVal = sizeof(timeval);
    if (setsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, timeoutValSizeInTimeVal) != SOCKET_ERROR)
    {
    int lastError = WSAGetLastError();
    printf("Error: %d\n", lastError);
    }


    //timeoutVal = 5000;
    //if (setsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeoutVal, timeoutValSizeInInt) != SOCKET_ERROR)
    //{
    // int lastError = WSAGetLastError();
    // printf("Error: %d\n", lastError);
    //}


    if (getsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, &timeoutValSizeInTimeVal) != SOCKET_ERROR)
    {
    int lastError = WSAGetLastError();
    printf("Error: %d\n", lastError);
    }
    if (getsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeoutVal, &timeoutValSizeInInt) != SOCKET_ERROR)
    {
    int lastError = WSAGetLastError();
    printf("Error: %d\n", lastError);
    }


    iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);


    if (iResult > 0) {
    printf("Bytes received: %d\n", iResult);


    // Echo the buffer back to the sender
    iSendResult = send(ClientSocket, recvbuf, iResult, 0);
    if (iSendResult == SOCKET_ERROR) {
    printf("send failed with error: %d\n", WSAGetLastError());
    closesocket(ClientSocket);
    WSACleanup();
    return 1;
    }
    printf("Bytes sent: %d\n", iSendResult);
    }
    else if (iResult == 0)
    printf("Connection closing...\n");
    else {
    printf("recv failed with error: %d\n", WSAGetLastError());
    closesocket(ClientSocket);
    WSACleanup();
    return 1;
    }


    } while (iResult > 0);


    // shutdown the connection since we're done
    iResult = shutdown(ClientSocket, SD_SEND);
    if (iResult == SOCKET_ERROR) {
    printf("shutdown failed with error: %d\n", WSAGetLastError());
    closesocket(ClientSocket);
    WSACleanup();
    return 1;
    }


    // cleanup
    closesocket(ClientSocket);
    WSACleanup();


    return 0;
    }

    :)
     
    Simon Guo, Mar 29, 2019
    #1
  2. Ahhzz Win User

    Office 2019

    Only supported on Win10. Sorry, 8.1 users, only 4 years old, gotta go.

    Microsoft Office 2019 will only work on Windows 10

    https://blogs.technet.microsoft.com...-to-office-and-windows-servicing-and-support/

    Spoiler Office 2019
    Last year at Ignite, we announced Office 2019 – the next perpetual version of Office that includes apps (including Word, Excel, PowerPoint, and Outlook, and Skype for Business) and servers (including Exchange, SharePoint, and Skype for Business). Today we’re pleased to share the following updates:

    • Office 2019 will ship in H2 of 2018. Previews of the new apps and servers will start shipping in the second quarter of 2018.
    • Office 2019 apps will be supported on:
      • Any supported Windows 10 SAC release
      • Windows 10 Enterprise LTSC 2018
      • The next LTSC release of Windows Server
    • The Office 2019 client apps will be released with Click-to-Run installation technology only. We will not provide MSI as a deployment methodology for Office 2019 clients. We will continue to provide MSI for Office Server products.
     
    Ahhzz, Mar 29, 2019
    #2
  3. Pinchy Win User
    Windows server 2003 timeouts

    I just built my new server PC and installed windows server 2003.

    The problem I get is when I am on the server (not my computer), I try to copy a large file/folder from my computer to the server, and it times out (like 300mb+, anything under generally goes through without probs).

    The strange thing is though, if I send data from the server to my computer (just tested an 800mb folder), it goes through without hassles.

    (ALL by operating on the server computer, my computer remains untouched, just powered on to access the drives)

    Just a bit of a background, I have installed a gigabit network card into the server via PCI. When I use the onboard 10/100 network, there are no timeouts. I figure its some sort of a setting (doubt its a firewall, esp seeing as it works fine with the onboard 10/100)

    The timeout message is something along the lines of: "Can't find the network anymore" (even though the network is still up and running)

    Thanks in adv *Smile Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the... :)
     
    Pinchy, Mar 29, 2019
    #3
  4. Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the...

    windows xp installation and dual core am

    could someone please list the steps they follow to install windows with a dual core processor and windows xp service pack to. I'm reletively new to amd dual core and i feel i'm missing a step. All help will be appreciated. thanx
     
    exodusprime1337, Mar 29, 2019
    #4
Thema:

Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the...

Loading...
  1. Windows Server 2019 - Windows socket receive timeout does not respect to the setting in the... - Similar Threads - Server 2019 socket

  2. Windows server 2019

    in Windows 10 Gaming
    Windows server 2019: I have a Key to activate Windows Server 2019. Currently on the PC I have Windows Server 2019 Evaluation with GUI installed. When I try to activate it through the activation tab I get the error code 0x80070032 returned. I can provide more information if needed, i am also...
  3. Windows server 2019

    in Windows 10 Software and Apps
    Windows server 2019: I have a Key to activate Windows Server 2019. Currently on the PC I have Windows Server 2019 Evaluation with GUI installed. When I try to activate it through the activation tab I get the error code 0x80070032 returned. I can provide more information if needed, i am also...
  4. Windows "respects" power settings???

    in Windows 10 Gaming
    Windows "respects" power settings???: windows "respects" power settings???????????????"What? How?" MemeNOTE: This is not a question. I just want to post this for fun. https://answers.microsoft.com/en-us/windows/forum/all/windows-respects-power-settings/6c0ca8f2-59cb-4ed1-b7ad-b1090af39833
  5. Windows "respects" power settings???

    in Windows 10 Software and Apps
    Windows "respects" power settings???: windows "respects" power settings???????????????"What? How?" MemeNOTE: This is not a question. I just want to post this for fun. https://answers.microsoft.com/en-us/windows/forum/all/windows-respects-power-settings/6c0ca8f2-59cb-4ed1-b7ad-b1090af39833
  6. Does it cost to upgrade windows server 2016 to server 2019?

    in Windows 10 Installation and Upgrade
    Does it cost to upgrade windows server 2016 to server 2019?: Do I need to pay to upgrade windows server 2016 to 2019? https://answers.microsoft.com/en-us/windows/forum/all/does-it-cost-to-upgrade-windows-server-2016-to/2fdefc6b-d1d9-4629-95d3-b0c5f3fe2f22
  7. Windows search does not respect dark mode

    in Windows 10 Ask Insider
    Windows search does not respect dark mode: Hello. If I <Win+S>, or indeed just <Win> and then start typing, the resulting search window is displayed with a white background and white text. Which would be fine except I have enabled dark mode (Turn on dark mode for apps) so it looks awful and kind of ruins the...
  8. Windows respect my settings.

    in Windows 10 Customization
    Windows respect my settings.: Can you believe this OS can't get something as simple as time right, I have been late for appointments because it decided to roll back my time by an hour, I have been dealing with this for months now, last week it really crushed me when it went back 2 hours which it has never...
  9. Windows Server 2019

    in Windows 10 BSOD Crashes and Debugging
    Windows Server 2019: Hello, I have a question to the new Windows Server 2019. Is it possible to divide a windows host server for performance sharing? With multiple users working on it at the same time. As an example, that multiple users can play simultaneously on this server? Thus, only the...
  10. Windows Server 2019

    in Windows 10 Installation and Upgrade
    Windows Server 2019: My family is using Windows 2016 Essentials. What is our upgrade path to Windows 2019 Server? Our server has 2 cores. https://answers.microsoft.com/en-us/windows/forum/all/windows-server-2019/e0e655e0-af27-4955-86f2-32f015eb0fff

Users found this page by searching for:

  1. windows server 2019 tcp timeout