Hello, I'm developing an application that needs to interact over FTP. For this communication I am currently using C++, Visual Studio and Poco on Windows.
The following line results in a bad_alloc exception...
ftp = new FTPClientSession("127.0.0.1", 21);
So I went down and tried initializing a StreamSocket first, also fails...
StreamSocket ss = new SocketAddress("127.0.0.1", 21);
When going even further down, and it seems the bad_alloc is coming from:
IPAddress * ip = new IPAddress("127.0.0.1");
That constructor contains: (I see in the debugger that _pImpl isn't initialised)
IPAddress::IPAddress(const std::string& addr)
{
_pImpl = IPv4AddressImpl::parse(addr);
if (!_pImpl) throw InvalidAddressException(addr);
}
IPv4AddressImpl::parse contains:
static IPv4AddressImpl* parse(const std::string& addr)
{
if (addr.empty()) return 0;
#if defined(_WIN32)
struct in_addr ia;
ia.s_addr = inet_addr(addr.c_str());
if (ia.s_addr == INADDR_NONE && addr != "255.255.255.255")
return 0;
else
return new IPv4AddressImpl(&ia);
#else
#if __GNUC__ < 3
struct in_addr ia;
ia.s_addr = inet_addr(addr.c_str());
if (ia.s_addr == INADDR_NONE && addr != "255.255.255.255")
return 0;
else
return new IPv4AddressImpl(&ia);
#else
struct in_addr ia;
if (inet_aton(addr.c_str(), &ia))
return new IPv4AddressImpl(&ia);
else
return 0;
#endif
#endif
}
The following code with inet_addr from Winsock2.h (ws2_32.lib) results in "SOMETHING ELSE".
unsigned long ulAddr = INADDR_NONE;
ulAddr = inet_addr("91.183.48.210");
if (ulAddr == INADDR_NONE)
msg("NONE");
else
msg("SOMETHING ELSE");
I don't see what is going wrong here... Is there a way to debug this further or does someone know what goes wrong?