Multi-Tech Systems 92U12616852 ユーザーズマニュアル

ページ / 76
USING LINUX WITH H5 DEVICES
write()
The write() function writes nbyte bytes from the buffer that are pointed by buf to the file associated with the open
file descriptor. fildes.
Header File
unistd.h
Prototype:
ssize_t write(int fildes, const void *buf, size_t nbyte)
Parameters:
fildes – file descriptor
buf – destination buffer pointer
nbyte – number of bytes that write() attempts to write
Returns:
The number of bytes actually written if the operation is completed successfully, otherwise it is -1.
Example
Write strlen(value_to_be_written) bytes from the buffer pointed by value_to_be_written to the file
associated with the open file descriptor, fd.
char value_to_be_written[] = “dummy_write”;
if (write(fd, value_to_be_written, strlen(value_to_be_written)) < 0)
{
/* Error Management Routine */
} else {
/* Value Written */
}
close()
The close() function shall deallocate the file descriptor indicated by fildes. To deallocate means to make the file
descriptor available for return by subsequent calls to open() or other functions that allocate file descriptors.
Header File
unistd.h
Prototype:
int close(int fildes);
Parameters:
fildes - file descriptor
Returns:
0 if successful, otherwise it is -1.
72
MultiConnect
TM
PCIe MTPCIE-H5/MTPCIE-BW Developer Guide