MCPcopy Create free account
hub / github.com/FastLED/FastLED / handle_connecting

Method handle_connecting

src/fl/net/http/fetch_request.cpp.hpp:172–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void FetchRequest::handle_connecting() {
173 fd_set write_fds;
174 FD_ZERO(&write_fds);
175 FD_SET(mSocketFd, &write_fds);
176
177 struct timeval timeout;
178 timeout.tv_sec = 0;
179 timeout.tv_usec = 0; // Non-blocking check
180
181 int result = select(mSocketFd + 1, nullptr, &write_fds, nullptr, &timeout);
182
183 if (result > 0) {
184 // Check for connection errors
185 int sock_err = 0;
186 socklen_t len = sizeof(sock_err);
187 getsockopt(mSocketFd, SOL_SOCKET, SO_ERROR, (char*)&sock_err, &len);
188
189 if (sock_err != 0) {
190 complete_error("Connection failed");
191 return;
192 }
193
194 // Connected! Build HTTP request
195 mRequestBuffer = "GET " + mPath + " HTTP/1.1\r\n";
196 mRequestBuffer += "Host: " + mHostname + "\r\n";
197 mRequestBuffer += "Connection: close\r\n\r\n";
198
199 mBytesSent = 0;
200 mState = SENDING;
201 mStateStartTime = fl::millis();
202 } else if (result < 0) {
203 complete_error("select() failed during connection");
204 } else {
205 // Timeout check (5 seconds)
206 if (fl::millis() - mStateStartTime > 5000) {
207 complete_error("Connection timeout");
208 }
209 // else: Not ready yet, try again on next update()
210 }
211}
212
213void FetchRequest::handle_sending() {
214 ssize_t sent = send(mSocketFd,

Callers

nothing calls this directly

Calls 3

selectFunction · 0.85
getsockoptFunction · 0.50
millisFunction · 0.50

Tested by

no test coverage detected