1

Well.. I am not really sure what that means, but my systems runs and runs and runs without crying for insufficient memeory...

I guess it has to do with the system error 122, because there is no 122 in the winsock error codes (MSDN)...

Anyone got a clue?...

It occures on a call to getaddrinfo(NULL, /*PortNumber*/, &hints, &pFinal)

EDIT alright... heres more code (having it not commented out, doesn´t make sense, too)

            addrinfo hints, *pFinal = nullptr;
            memset(&hints, 0, sizeof(hints));
            hints.ai_flags = AI_PASSIVE;
            hints.ai_socktype = SOCK_STREAM;
            hints.ai_family = AF_INET;

            if(getaddrinfo(NULL, g_ACCEPTOR_PORT_NUMBER, &hints, &pFinal))
                return ERROR_BIND_SOCKET;

The Problem lies in my g_ACCEPTOR_PORT_NUMBER, which is a class containing

operator const char*()
    {
        std::stringstream ss;
        ss << m_nPortNumber;
        return ss.str().c_str();
    }

do I have to change the conversion operator?... I´d prefer to use this "STRINGINT" so i dont need to save the port number as string and number or convert it explicitly...

glglgl
  • 89,107
  • 13
  • 149
  • 217
Juarrow
  • 2,232
  • 5
  • 42
  • 61

4 Answers4

2

Probably a bad parameter on the getaddrinfo call. Can you post more code?

Type in net helpmsg 122 at a command prompt and you get:

The data area passed to a system call is too small.

Steve Townsend
  • 53,498
  • 9
  • 91
  • 140
  • Have that operator return a `std::string` so the data does not go out of scope when `ss.str()` gets destructed – Steve Townsend Dec 06 '10 at 17:26
  • the problem is, that getaddrinfo takes a const char* and not a str... i try not to use c_str()... but i guess that i have to^^... – Juarrow Dec 06 '10 at 18:37
  • If you want to encapsulate the port in that way, you are going to have to allow getting of its string equivalent in some way. Returning a `string` and then passing `.c_str()` to the WIn32 API does not seem too messy, does it? The Win32 APIs are C-oriented so some compromises are inevitable. – Steve Townsend Dec 06 '10 at 18:38
1

getaddrinfo actually returns an error code, which you should test against the values specified in the getaddrinfo documentation

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
1

The problem is your implementation of operator const char*(). Once that function returns, your stringstream object is no longer valid because it is no longer in scope.

Aaron Klotz
  • 11,287
  • 1
  • 28
  • 22
0

More than likely, the size of the pFinal variable is too small. You'll need to post more code to get a more thorough answer.

Zac Howland
  • 15,777
  • 1
  • 26
  • 42
  • If it would be, then Microsoft´s programmers had done some incredibly wrong... Did You even read the code and my comments below the EDIT?= – Juarrow Dec 06 '10 at 17:06