cucumber / cucumber-cpp

Support for writing Cucumber step definitions in C++
MIT License
309 stars 132 forks source link

Cucumber cannot connect to wire server on windows #177

Closed pp23 closed 10 months ago

pp23 commented 6 years ago

Summary

We have installed cucumber and the examples on windows with the msvc compiler. When trying for instance the Calc-example cucumber does not get a connection to the wire server running on localhost. There is no error, just the requirements are printed as "undefined". The wire server is available on localhost and we could connect to it with a connection test tool. So we wonder why cucumber is not able to connect to the server.

Expected Behavior

Cucumber connects to the wire server and runs the requirements. The requirements are not "undefined".

Current Behavior

Cucumber does not connect to the wire server and requirements are "undefined".

Possible Solution

Steps to Reproduce (for bugs)

  1. Install cucumber and examples with msvc on windows
  2. Start the calc-example
  3. Run cucumber with the calc-features

Context & Motivation

Your Environment

Windows 7, MSVC 2010

elominp commented 6 years ago

I've got the same issue with Cucumber 2.1.0 (also tried 3.x and other versions of 2.x branch) on Windows 10 ans MSVC 14.0 (2015). However, the issues seems to come from Cucumber itself and not from Cucumber-cpp as Cucumber doesn't connect at all to the Wire server.

For example, compiling and running this little snippet of code open a socket to the Wire server then close it immediately causes the Wire server to close normally, which doesn't happen with Cucumber:

#ifdef _WIN32
# pragma comment( lib, "ws2_32.lib")
#endif /* _WIN32 */
#include <Winsock2.h>
#include <stdio.h>

int main() {
    // Initialize Winsock
    WSADATA wsaData;
    int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
    auto sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (sock == INVALID_SOCKET) {
        wprintf(L"socket failed with error: %ld\n", WSAGetLastError());
        WSACleanup();
        return 1;
    }
    sockaddr_in in;
    in.sin_family = AF_INET;
    in.sin_addr.s_addr = inet_addr("127.0.0.1");
    in.sin_port = htons(3902);
    iResult = connect(sock, reinterpret_cast<SOCKADDR *>(&in), sizeof(in));
    if (iResult == SOCKET_ERROR) {
        wprintf(L"connect failed with error: %d\n", WSAGetLastError() );
        closesocket(sock);
        WSACleanup();
        return 1;
    }
    closesocket(sock);
    WSACleanup();
    return 0;
}
ursfassler commented 10 months ago

Please reopen this issue if it is not resolved for you. In the case it works for you, I would appreciate if you can help others by doing one or more: