Skip to content

Commit 084706e

Browse files
committed
Increase the socket timeout, extra logging
1 parent 234e7fe commit 084706e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/av.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ void *BatteryThreadProc(__attribute__((__unused__)) void *args) {
5656
}
5757

5858
if (Send(BATTERY_REQ, CSTR_LEN(BATTERY_REQ), socket) <= 0) {
59-
errprint("error sending battery status request\n");
59+
errprint("error sending battery status request: (%d) '%s'\n",
60+
errno, strerror(errno));
6061
goto LOOP;
6162
}
6263

@@ -125,6 +126,7 @@ void *VideoThreadProc(void *args) {
125126

126127
len = snprintf(buf, sizeof(buf), VIDEO_REQ, decoder_get_video_width(), decoder_get_video_height());
127128
if (Send(buf, len, videoSocket) <= 0){
129+
errprint("send error (%d) '%s'\n", errno, strerror(errno));
128130
MSG_ERROR("Error sending request, DroidCam might be busy with another client.");
129131
goto early_out;
130132
}
@@ -245,12 +247,14 @@ void *AudioThreadProc(void *arg) {
245247
}
246248

247249
if (Send(AUDIO_REQ, CSTR_LEN(AUDIO_REQ), socket) <= 0) {
250+
errprint("send error (audio) (%d) '%s'\n", errno, strerror(errno));
248251
MSG_ERROR("Error sending audio request");
249252
goto early_out;
250253
}
251254

252255
memset(stream_buf, 0, 6);
253256
if (RecvAll(stream_buf, 6, socket) <= 0) {
257+
errprint("recv error (audio) (%d) '%s'\n", errno, strerror(errno));
254258
MSG_ERROR("Audio connection reset!");
255259
goto early_out;
256260
}
@@ -277,7 +281,10 @@ void *AudioThreadProc(void *arg) {
277281
int len = (mode == UDP_STREAM)
278282
? RecvNonBlockUDP(stream_buf, STREAM_BUF_SIZE, socket)
279283
: RecvNonBlock (stream_buf, STREAM_BUF_SIZE, socket);
280-
if (len < 0) { goto early_out; }
284+
if (len < 0) {
285+
errprint("recv error (audio) (%d) '%s'\n", errno, strerror(errno));
286+
goto early_out;
287+
}
281288

282289
if (len > 0) {
283290
// dbgprint("recv %d frames\n", (len / DROIDCAM_SPX_CHUNK_BYTES_2));

src/connection.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ SOCKET Connect(const char* ip, int port, char **errormsg) {
7575
flags &= ~O_NONBLOCK;
7676
fcntl(sock, F_SETFL, flags);
7777

78+
timeout.tv_sec = 5;
7879
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0
7980
|| setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0)
8081
perror("setsockopt failed");

0 commit comments

Comments
 (0)