Create a new socket.
Syntax
#include <sys/socket.h>
int socket (int domain, int type, int protocol);
Parameters
-
domain
Address family (network stack / type) the socket will be created for.
-
AF_INET
: Normally IPv4, but used by the RS422 stack. -
66
: CSP
-
-
type
Socket type within the domain. The only type known to be implemented at the moment is
SOCK_DGRAM
. -
protocol
Specifies the protocol to use for the socket type. Currently not used, and should be set to zero.
Return Value
The return value is a new file descriptor if successful. Otherwise, the return value is negative and errno is set:
-
ENOSYS
Socket domain unknown. If the socket domain is implemented by a networking stack in userspace, check that the program is running and has successfully registered itself with the kernel.
-
ENOMEM
Out of memory.
Out of free file descriptors.
Remarks
See the documentation for the correct socket address family (network stack) for details related to it.