Improved timeout
This commit is contained in:
parent
bad1e6c08c
commit
1c06417c48
1 changed files with 5 additions and 3 deletions
|
|
@ -6,9 +6,11 @@
|
|||
#define COLOR_BOLD "\x1b[1m"
|
||||
#define COLOR_RESET "\x1b[0m"
|
||||
|
||||
#define LOSS_RATE 5
|
||||
#define TIMEOUT 2
|
||||
|
||||
struct mic_tcp_sock g_sock;
|
||||
int next_msg_num;
|
||||
short timeout_msec = 5000;
|
||||
|
||||
/**
|
||||
* Permet de créer un socket entre l’application et MIC-TCP.
|
||||
|
|
@ -20,7 +22,7 @@ int mic_tcp_socket(start_mode sm) {
|
|||
printf(__FUNCTION__);
|
||||
printf("\n");
|
||||
result = initialize_components(sm); /* Appel obligatoire */
|
||||
set_loss_rate(50);
|
||||
set_loss_rate(LOSS_RATE);
|
||||
|
||||
g_sock.fd = result;
|
||||
g_sock.state = IDLE;
|
||||
|
|
@ -106,7 +108,7 @@ int mic_tcp_send(int socket, char *mesg, int mesg_size) {
|
|||
struct mic_tcp_pdu rcv_pdu;
|
||||
struct mic_tcp_sock_addr rcv_sock_addr;
|
||||
printf("[MIC-TCP] Waiting for ACK\n");
|
||||
result = IP_recv(&rcv_pdu, &rcv_sock_addr, timeout_msec);
|
||||
result = IP_recv(&rcv_pdu, &rcv_sock_addr, TIMEOUT);
|
||||
if (result == -1)
|
||||
printf("[MIC-TCP] "COLOR_BOLD"Timeout"COLOR_RESET"\n");
|
||||
else if (rcv_pdu.header.ack_num != next_msg_num + 1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue