Technical Support
On-Line Manuals
RL-ARM User's Guide (MDK v4)
#include <rtl.h> int socket ( int family, /* Address family. */ int type, /* Communication type. */ int protocol); /* Communication protocol */
The socket function creates a communication end point called a socket.
The argument family specifies the address family. Currently the only acceptable value is AF_INET.
The argument type specifies the communication semantics. The following are the currently supported types:
The argument protocol specifies the protocol that must be used with socket type:
The socket function is in the RL-TCPnet library. The prototype is defined in rtl.h.
note
The socket function returns the following result:
bind, closesocket, 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.