#include "gdbcmd.h"
#include "cli/cli-decode.h"
#include "cli/cli-setshow.h"
+#include "filestuff.h"
#include <sys/types.h>
/* Timeout period for connections, in seconds. */
-static int tcp_retry_limit = 15;
+static unsigned int tcp_retry_limit = 15;
/* How many times per second to poll deprecated_ui_loop_hook. */
Returns -1 on timeout or interrupt, otherwise the value of select. */
static int
-wait_for_connect (struct serial *scb, int *polls)
+wait_for_connect (struct serial *scb, unsigned int *polls)
{
struct timeval t;
int n;
#else
int ioarg;
#endif
- int polls = 0;
+ unsigned int polls = 0;
use_udp = 0;
if (strncmp (name, "udp:", 4) == 0)
retry:
if (use_udp)
- scb->fd = socket (PF_INET, SOCK_DGRAM, 0);
+ scb->fd = gdb_socket_cloexec (PF_INET, SOCK_DGRAM, 0);
else
- scb->fd = socket (PF_INET, SOCK_STREAM, 0);
+ scb->fd = gdb_socket_cloexec (PF_INET, SOCK_STREAM, 0);
if (scb->fd == -1)
return -1;
int
net_read_prim (struct serial *scb, size_t count)
{
- return recv (scb->fd, scb->buf, count, 0);
+ /* Need to cast to silence -Wpointer-sign on MinGW, as Winsock's
+ 'recv' takes 'char *' as second argument, while 'scb->buf' is
+ 'unsigned char *'. */
+ return recv (scb->fd, (void *) scb->buf, count, 0);
}
int
add_setshow_uinteger_cmd ("connect-timeout", class_obscure,
&tcp_retry_limit, _("\
-Set timeout limit for socket connection"), _("\
-Show timeout limit for socket connection"),
- NULL, NULL, NULL,
- &tcp_set_cmdlist, &tcp_show_cmdlist);
+Set timeout limit in seconds for socket connection"), _("\
+Show timeout limit in seconds for socket connection"), _("\
+If set to \"unlimited\", GDB will keep attempting to establish a\n\
+connection forever, unless interrupted with Ctrl-c.\n\
+The default is 15 seconds."),
+ NULL, NULL,
+ &tcp_set_cmdlist, &tcp_show_cmdlist);
}