| 122 | ConsoleUploadFile::~ConsoleUploadFile() {} |
| 123 | |
| 124 | void ConsoleUploadFile::uploadFile() |
| 125 | { |
| 126 | Data srcFileData = FileUtils::getInstance()->getDataFromFile(s_pathGrossini); |
| 127 | if (srcFileData.isNull()) |
| 128 | { |
| 129 | AXLOGE("ConsoleUploadFile: could not open file {}", s_pathGrossini); |
| 130 | } |
| 131 | |
| 132 | std::string targetFileName = _targetFileName; |
| 133 | |
| 134 | struct addrinfo hints; |
| 135 | struct addrinfo *result, *rp; |
| 136 | int sfd, s; |
| 137 | |
| 138 | /* Obtain address(es) matching host/port */ |
| 139 | |
| 140 | memset(&hints, 0, sizeof(struct addrinfo)); |
| 141 | hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ |
| 142 | hints.ai_socktype = SOCK_STREAM; /* stream socket */ |
| 143 | hints.ai_flags = 0; |
| 144 | hints.ai_protocol = 0; /* Any protocol */ |
| 145 | |
| 146 | #if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) |
| 147 | WSADATA wsaData; |
| 148 | WSAStartup(MAKEWORD(2, 2), &wsaData); |
| 149 | #endif |
| 150 | |
| 151 | std::string nodeName; |
| 152 | if (Director::getInstance()->getConsole()->isIpv6Server()) |
| 153 | nodeName = "::1"; |
| 154 | else |
| 155 | nodeName = "localhost"; |
| 156 | |
| 157 | s = getaddrinfo(nodeName.c_str(), "5678", &hints, &result); |
| 158 | if (s != 0) |
| 159 | { |
| 160 | AXLOGD("ConsoleUploadFile: getaddrinfo error"); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | /* getaddrinfo() returns a list of address structures. |
| 165 | Try each address until we successfully connect(2). |
| 166 | If socket(2) (or connect(2)) fails, we (close the socket |
| 167 | and) try the next address. */ |
| 168 | |
| 169 | for (rp = result; rp != nullptr; rp = rp->ai_next) |
| 170 | { |
| 171 | sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); |
| 172 | if (sfd == -1) |
| 173 | continue; |
| 174 | |
| 175 | if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) |
| 176 | break; /* Success */ |
| 177 | |
| 178 | #if defined(_WIN32) |
| 179 | closesocket(sfd); |
| 180 | #else |
| 181 | close(sfd); |
nothing calls this directly
no test coverage detected