Github user becrux commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/628#discussion_r45580255
  
    --- Diff: lib/cpp/src/thrift/server/TNonblockingServer.cpp ---
    @@ -1105,10 +1113,17 @@ void TNonblockingServer::listenSocket(THRIFT_SOCKET 
s) {
       serverSocket_ = s;
     
       if (!port_) {
    -    sockaddr_in addr;
    -    socklen_t size = sizeof(addr);
    -    if (!getsockname(serverSocket_, reinterpret_cast<sockaddr*>(&addr), 
&size)) {
    -      listenPort_ = ntohs(addr.sin_port);
    +    #ifdef _WIN32
    +      struct sockaddr_storage addr;
    +      struct sockaddr_in *pAddr = (sockaddr_in *) &addr;
    +      socklen_t size = sizeof(addr);
    +    #else
    +      struct sockaddr_in addr;
    +      struct sockaddr_in *pAddr = &addr;
    +      socklen_t size = sizeof(addr);
    +    #endif
    --- End diff --
    
    Well, I do not have an answer, but it seems an official Windows API, cause 
all "stackoverflow" posts I found are not related to MinGW usage. Even if you 
search through different blogs & forums, you'll find the same answer, and MinGW 
is not mentioned.
    
    Moreover, sample code reported in MSDN documentation comments uses 
getsockname in the same way:
    
    
https://msdn.microsoft.com/en-us/library/windows/desktop/ms738543(v=vs.85).aspx


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to