Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/fins.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#ifndef INCLUDED_FINSLIB_FINS_H
#define INCLUDED_FINSLIB_FINS_H
#ifdef __cplusplus
extern "C" {
#endif

#if defined(_MSC_VER)
#pragma warning(disable:4201 4668 4710 4711 4820 5045)
Expand Down Expand Up @@ -726,5 +729,7 @@ int XX_finslib_wsa_errorcode_to_fins_retval( int errorcode );


extern struct fins_mcap_tp fins_model[];

#ifdef __cplusplus
}
#endif
#endif
21 changes: 17 additions & 4 deletions src/fins_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ struct fins_sys_tp *finslib_tcp_connect( struct fins_sys_tp *sys, const char *ad
struct fins_sys_tp *finslib_udp_connect( struct fins_sys_tp *sys, const char *address, uint16_t port, uint8_t local_net, uint8_t local_node, uint8_t local_unit, uint8_t remote_net, uint8_t remote_node, uint8_t remote_unit, int *error_val, int error_max ) {

struct sockaddr_in ws_addr;
struct timeval tv ={ 0 };
#if ! defined(_WIN32)
struct timeval tv = { 0 };
#else
int tv = 0;
#endif /* ! defined(_WIN32) */

if ( sys != NULL && finslib_monotonic_sec_timer() < sys->timeout + FINS_TIMEOUT && sys->timeout > 0 ) {

Expand Down Expand Up @@ -381,13 +385,22 @@ struct fins_sys_tp *finslib_udp_connect( struct fins_sys_tp *sys, const char *ad

sys->sockfd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );

tv.tv_sec = SEND_TIMEOUT;
#if ! defined(_WIN32)
tv.tv_sec = SEND_TIMEOUT;
tv.tv_usec = 0;

#else
tv = SEND_TIMEOUT*1000;
#endif /* ! defined(_WIN32) */


if ( setsockopt( sys->sockfd, SOL_SOCKET, SO_SNDTIMEO, (setsockopt_tp *) & tv, sizeof(tv) ) < 0 ) return fins_close_socket_with_error( sys, error_val );

tv.tv_sec = RECV_TIMEOUT;
#if ! defined(_WIN32)
tv.tv_sec = RECV_TIMEOUT;
tv.tv_usec = 0;
#else
tv = RECV_TIMEOUT * 1000;
#endif /* ! defined(_WIN32) */

if ( setsockopt( sys->sockfd, SOL_SOCKET, SO_RCVTIMEO, (setsockopt_tp *) & tv, sizeof(tv) ) < 0 ) return fins_close_socket_with_error( sys, error_val );

Expand Down