Technical Support
On-Line Manuals
RL-ARM User's Guide (MDK v4)
#include <rtl.h> int listen ( int sock, /* Socket descriptor */ int backlog); /* Maximum number of connections */
The listen function sets the specified socket in a listening mode. Before calling the listen function, the bind function must be called.
The argument sock specifies a socket descriptor returned from a previous call to socket.
The argument backlog specifies a maximum number of connection requests that can be queued.
The listen function is in the RL-TCPnet library. The prototype is defined in rtl.h.
note
The bind function returns the result code:
accept, connect, ioctlsocket
#include <rtl.h> __task void server (void *argv) { /* Server task runs in 2 instances. */ SOCKADDR_IN addr; int sock, sd, res; int type = (int)argv; char dbuf[4]; while (1) { sock = socket (AF_INET, type, 0); addr.sin_port = htons(1001); addr.sin_family = PF_INET; addr.sin_addr.s_addr = INADDR_ANY; bind (sock, (SOCKADDR *)&addr, sizeof(addr)); if (type == SOCK_STREAM) { listen (sock, 1); sd = accept (sock, NULL, NULL); closesocket (sock); sock = sd; } while (1) { res = recv (sock, dbuf, sizeof (dbuf), 0); if (res <= 0) { break; } procrec ((U8 *)dbuf); } closesocket (sock); } }
Cookie Settings | Terms of Use | Privacy | Accessibility | Trademarks | Contact Us | Feedback
Copyright © 2005-2019 Arm Limited (or its affiliates). All rights reserved.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
Change Settings
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.