Logiciels Libres et Systèmes Embarqués

client_poll.c

Aller à la documentation de ce fichier.
00001 #include "global.h"
00002 #include "lwip/pbuf.h"
00003 
00004 #ifdef CLIENT
00005 
00006 err_t client_poll(void *arg, struct tcp_pcb *pcb)
00007 {
00008         struct pbuf *pbuf = NULL;
00009         err_t ret_code = ERR_OK;
00010         int client_close = *(int *)arg;
00011 
00012         pbuf = pbuf_alloc(PBUF_TRANSPORT, 4, PBUF_RAM);
00013         if(pbuf != NULL) {
00014                 ((char *)pbuf->payload)[0] = 'S';
00015                 ((char *)pbuf->payload)[1] = 'M';
00016                 ((char *)pbuf->payload)[2] = 'P';
00017                 ((char *)pbuf->payload)[3] = '\0';
00018                 
00019                 (void) tcp_write(pcb, pbuf->payload, pbuf->len, 1);
00020                 tcp_sent(pcb, client_sent);
00021                 
00022                 pbuf_free(pbuf);
00023 
00024                 if(1 == client_close)
00025                         ret_code = tcp_close(pcb);
00026         }
00027 
00028         return ret_code;
00029 }
00030 
00031 #endif //CLIENT