For Windows: Not Supported
The %socket() function 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 addr.family.
Syntax
n = %socket(addr.family, type, protocol)
Parameter(s)
|
addr.family |
Specifies the addressing scheme used later to decode addresses. Valid values are defined in the include file: 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. |
|
Description
To compile successfully, the statement cfunction socket.builtin must be included in the source code.
Upon successful completion, a valid file descriptor is returned. If the call fails, a value of -1 is returned and the system(0) function returns the value of errno.
The socket is closed by a %close call or automatically when the FlashBASIC program terminates.
|
NOTE— |
Sockets are a Berkeley Software Distribution (BSD) extension, which may not be available on all UNIX implementations. |
Example(s)
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)
See Also