There is no such feature (at least, something really standard), since sockets 
API paradigm is not to use events, but more to use synchronous function calls. 
But you could use "select" or the SO_RCVTIMEO option to perform a receive with 
timeout to avoid to block your task. 

 
  
====================================
Frédéric BERNON 
HYMATOM SA 
Chef de projet informatique 
Microsoft Certified Professional 
Tél. : +33 (0)4-67-87-61-10 
Fax. : +33 (0)4-67-70-85-44 
Email : [email protected] 
Web Site : http://www.hymatom.fr 

Plan d'accès au siège social 

====================================
P Avant d'imprimer, penser à l'environnement


-----Message d'origine-----
De : [email protected] 
[mailto:[email protected]] De la part de 
Mathias Zenger
Envoyé : mardi 28 avril 2009 13:49
À : [email protected]
Objet : [lwip-users] recv callback function for sockets?


Hi,

I am using lwIP in context with FreeRTOS and try to write a NTP client. I have 
a task which is called fix every 1000 ms. In the task loop I either send out a 
UDP request to a NTP server or poll recvfrom() for received UDP replies. For 
communication I am using the socket API.

My problem is that I should process the received packets immediately. Polling 
recvfrom() every second is too slow. I am wondering if it's possible to 
register a callback function which will be called as soon a packet was received 
-> similar to udp_recv(). How would I have to use it with sockets??

Thanks for helping! Best regards,
Mathias


Additional information:

- My socket is non-blocking: lwip_ioctl(fd, FIONBIO, &noblock_true);
- Sending out my request datagram works fine: sendto(fd, &snd_buffer, 
sizeof(snd_buffer), 0, (struct sockaddr *)&addr, addr_length);
- Reception basically works fine too: recvfrom(fd, &rec_buffer, 
sizeof(rec_buffer), 0, (struct sockaddr *)&addr, &addr_length);




_______________________________________________
lwip-users mailing list
[email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
BEGIN:VCARD
VERSION:2.1
N:BERNON;Frédéric;;M.
FN:Frédéric BERNON
ORG:HYMATOM SA;Recherche et Développement
TITLE:Chef de projet informatique
TEL;WORK;VOICE:04-67-87-61-10
TEL;WORK;FAX:04-67-70-85-44
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;23;Zone Industrielle=0D=0A175 rue de Massacan;VENDARGUES;;34740;FRANCE;
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:23=0D=0AZone Industrielle=0D=0A175 rue de Massacan=0D=0AVENDARGUES 34740=0D=
=0AFrance
URL;WORK:http://www.hymatom.fr
ROLE:Chef de projet informatique
EMAIL;PREF;INTERNET:[email protected]
REV:20020404T083210Z
END:VCARD
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to