Use memcpy to set filedescriptor and timevalue.

merge-requests/3/merge
Teuniz 2021-03-12 14:42:33 +01:00
rodzic 573b1e68fe
commit 8c3774ecbc
2 zmienionych plików z 17 dodań i 7 usunięć

Wyświetl plik

@ -35,7 +35,7 @@
#define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.37_2103120950"
#define PROGRAM_VERSION "0.37_2103121438"
#define MAX_PATHLEN 1024

Wyświetl plik

@ -71,8 +71,13 @@ static int tmclan_send(const char *str)
{
int len;
fd_set temp_tcp_fds = tcp_fds; /* because select overwrites the arguments */
struct timeval temp_timeout = timeout;
fd_set temp_tcp_fds;
struct timeval temp_timeout;
memcpy(&temp_tcp_fds, &tcp_fds, sizeof(fd_set)); /* because select overwrites the arguments */
memcpy(&temp_timeout, &timeout, sizeof(struct timeval));
len = strlen(str);
@ -83,7 +88,7 @@ static int tmclan_send(const char *str)
len = send(sockfd, str, len, MSG_NOSIGNAL);
if(len == -1)
{
perror("send()");
perror("*** error *** send()");
}
return len;
@ -91,7 +96,7 @@ static int tmclan_send(const char *str)
}
else
{
perror("select()");
perror("*** error *** select()");
}
return -1;
@ -100,8 +105,13 @@ static int tmclan_send(const char *str)
static int tmclan_recv(char *buf, int sz)
{
fd_set temp_tcp_fds = tcp_fds; /* because select overwrites the arguments */
struct timeval temp_timeout = timeout;
fd_set temp_tcp_fds;
struct timeval temp_timeout;
memcpy(&temp_tcp_fds, &tcp_fds, sizeof(fd_set)); /* because select overwrites the arguments */
memcpy(&temp_timeout, &timeout, sizeof(struct timeval));
if(select(sockfd + 1, &temp_tcp_fds, 0, 0, &temp_timeout) != -1)
{