| %SHMGET | Index Level | %TTYNAME |
| Syntax | n = %SOCKET( addr.family, type, protocol ) |
| Category | BASIC |
| Type | C Function |
| Description |
creates a socket in the specified 'addr.family' and of the specified 'type'. A protocol can be specified or assigned by the system. If the protocol is left unspecified (with a value of 0), the system selects an appropriate protocol in the specified address family.
To compile successfully, the statement 'cfunction socket.builtin' must be included in the source code. 'addr.family' Specifies the addressing scheme which will be used later to decode addresses. Valid values are defined in the include "dm,bp,unix.h socket.h". Commonly used values are: AF$UNIX Unix path names. AF$INET ARPA Internet. 'type' Specifies the semantics of communication. Valid values are defined in the include "dm,bp,unix.h socket.h". Commonly used values are: SOCK$STREAM Unix streams. SOCK$DGRAM Datagram 'protocol' Should be left to 0, to let the system assign the protocol. Upon successful completion, a valid file descriptor is returned. If the call fails, a value of -1 is returned and the function 'SYSTEM(0)' returns the value of 'errno'. The socket is closed by a %close call or automatically when the basic program terminates |
| Options | |
| See Also | CFUNCTION %CLOSE %BIND %ACCEPT %LISTEN %GETHOSTID %CONNECT tape-socket |
| Example |
cfunction socket.builtin
include dm,bp,unix.h socket.h fd=%socket( AF$INET, SOCK$STREAM, 0 ) if fd<0 then crt 'Socket creation failed. Error ':system(0) |
| Warnings | Sockets are a BSD extension, which may not be available on all Unix implementations. |
| Compatibility | D3/Unix |
| %SHMGET | Index Level | %TTYNAME |