Alexandre, Use socket notices.
1. Register to receive a notification, either procedural or app launch. 2. Prepare a socket to do what you need to do (stream or datagram). 3. Prime the socket to send a socket notice (notifications are the only type supported by OS5). 4. When data arrives (or an error or shutdown), a deferred notification will be sent by NetLib. 5. When you receive the notification, service the socket and then re-prime the socket (one notice per prime). A socket can be primed to send a notice on any combination of data receipt, inbound connect, error or shutdown. Unfortunately, outbound connect was overlooked. NOTES: 1. Socket notices use a deferred notification, meaning the notification will not be broadcast until the foreground app calls EvtGetEvent(). 2. Socket notices are one-shot and must be reset after each trigger. You can do it in the notification handler, if it is convenient. 3. The option argument passed in NetLibSocketOptionSet() in this case is the address of a void pointer which points to the NetSocketNoticeType. Kind of confusing. 4. There is sample socket notice code provided in the knowledge base, but it is not very clear. Try something like the following to prime the socket to send a notice: // Refer to NetMgr.h for socket notice options. Int16 AsyncSocketSetup(SOCKET sock, UInt32 condition) { NetSocketNoticeType notice; void *option; notice.condition = condition; // some combination of conditions from NetMgr.h notice.type = netSocketNoticeNotify; notice.notice.notify.notifyType = <your selected notification ID>; option = ¬ice; // note the address of the pointer is used if (NetLibSocketOptionSet( NetLibRefnum, sock, netSocketOptLevelSocket, netSocketOptSockNotice, &option, sizeof(option), NetLibTimeout, &NetLibErrno)) { TRACE("AsyncSocketSetup() cannot set socket notice: %x",NetLibErrno); return -1; } return 0; } Hope this helps. Jeff -------------------- Jeff Loucks Work 425-284-1128 [EMAIL PROTECTED] Home 253-851-8908 [EMAIL PROTECTED] Mobile 253-691-8812 -----Original Message----- From: Alexandre Barreto [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 07, 2005 5:38 AM To: Palm Developer Forum Subject: Re: Reciving Data in a Socket My friend Regis said i was a litle confusing in my post. what i want to know is How do I specify a function to be called automaticaly when there is data received on a socket (a call back or a notification) thanx Alexandre Barreto escreveu: > Hi, > > I need to call a function evertime there is data on a socket. > i canīt block my program wating for data there. i need the user to do other stuffs..and when data arrives this function read the socket and do stuffs. > > how can i do that? > > thank you, > Alexandre -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/