io.h


Use the links in the table of contents to the left to access the documentation.

Includes <sys/types.h>, <stdint.h>, <arpa/inet.h>


Classes

NSData
NSString


Functions

read_block
read_data_memory
read_string
read_string_memory
read_unsigned_int
read_unsigned_int_memory
read_unsigned_short
safe_close
safe_read
safe_recv
write_data
write_string(int, NSData *)
write_string(int, unsigned char *, uint16_t)
write_unsigned_int
write_unsigned_short

read_block


ssize_t read_block(
    int fd,
    void *buf,
    size_t count);  
Parameters
fd

The file descriptor to read bytes from.

buf

The buffer where to store the read bytes.

count

The number of bytes to read.

Return Value

The number of bytes that have been read.

Discussion

This function is used to read count bytes from fd and store them in buf. This method blocks until it read all bytes or if an error different from EINTR occurs.


read_data_memory


NSData *read_data_memory(
    unsigned char *m,
    uint16_t *count);  
Parameters
m

The buffer to read from.

count

The lenght of the data returned

Return Value

The read NSData* (autoreleased)

Discussion

This function is used to read a string from m and return it as a NSData objectand adjust the count on how long the read data is. The data must NOT be longer than 65535 bytes.


read_string


ssize_t read_string(
    int fd,
    char *buf,
    uint16_t *count);  
Parameters
fd

The file descriptor to read from.

buf

The buf to write to.

count

The number of bytes that have been declared as string length.

Return Value

actual bytes of string read

Discussion

This function is used to read a string from a file descriptor, store it into a buffer and adjust the number of bytes that has been read.


read_string_memory


NSString *read_string_memory(
    unsigned char *m,
    uint16_t *count);  
Parameters
m

The buffer to read from.

count

The lenght of the string stored in buf

Return Value

The allocated string (autoreleased)

Discussion

This function is used to read a string from m and adjust the count on how long the string is. The string must NOT be longer than 65535 bytes.


read_unsigned_int


int read_unsigned_int(
    int fd,
    uint32_t *val);  
Parameters
fd

The file descriptor to read from.

Return Value

The unsigned int read from the file descriptor.

Discussion

This function is used to read an unsigned int from the file descriptor in network byte-order.


read_unsigned_int_memory


uint32_t read_unsigned_int_memory(
    unsigned char *m);  
Parameters
m

The buffer to read from.

Return Value

The unsigned integer read from memory.

Discussion

This function is used to read an unsigned int from the memory in network byte-order.


read_unsigned_short


uint16_t read_unsigned_short(
    int fd);  
Parameters
fd

The file descriptor to read from.

Return Value

The unsigned short read from the file descriptor.

Discussion

This function is used to read an unsigned short from the file descriptor in network byte-order.


safe_close


int safe_close(
    int fd);  
Parameters
fd

The file descriptor to close.

Return Value

Returns 0 on success, -1 if an error occurs.

Discussion

This function is used to safely close a file descriptor. This function will block until the file descriptor is close, or if the error is different from EINTR.


safe_read


ssize_t safe_read(
    int fd,
    void *buf,
    size_t count);  
Parameters
fd

The file descriptor to read bytes from.

buf

The buffer where to store the read bytes.

count

The number of bytes to read.

Return Value

The number of bytes that have been read.

Discussion

This function is used to read count bytes from fd and store them in buf. This method might not block when reading if there are no bytes available to be read.


safe_recv


ssize_t safe_recv(
    int fd,
    void *buf,
    size_t count,
    int flags);  
Parameters
fd

The file descriptor to read bytes from.

buf

The buffer where to store the read bytes.

count

The number of bytes to read.

flags

The flags to use.

Return Value

The number of bytes that have been read.

Discussion

This function is used to read count bytes from fd and store them in buf. This method might not block when reading if there are no bytes available to be read. Options can be passed through flags.


write_data


void write_data(
    int fd,
    NSData *d);  
Parameters
fd

The file descriptor to write to.

d

The NSData that needs to be written.

Discussion

This function is used to write NSData as a string to a file descriptor. The whole length is written


write_string(int, NSData *)


void write_data(
    int fd,
    NSData *d);  
Parameters
fd

The file descriptor to write to.

d

The NSData that needs to be written.

Discussion

This function is used to write NSData as a string to a file descriptor. The whole length is written


write_string(int, unsigned char *, uint16_t)


void write_string(
    int fd,
    unsigned char *s,
    uint16_t len);  
Parameters
fd

The file descriptor to write to.

buf

The buf that needs to be written.

count

The number of bytes that we have to write.

Discussion

This function is used to string a string to a file descriptor.


write_unsigned_int


void write_unsigned_int(
    int fd,
    uint32_t value);  
Parameters
fd

The file descriptor to write to.

value

The unsigned value to write.

Discussion

This function is used to write the specified unsigned int value to the file descriptor fd. The written value is in network byte-order.


write_unsigned_short


void write_unsigned_short(
    int fd,
    uint16_t value);  
Parameters
fd

The file descriptor to write to.

value

The unsigned value to write.

Discussion

This function is used to write the specified unsigned short value to the file descriptor fd. The written value is in network byte-order.


Macro Definitions

_Pantomime_H_io

_Pantomime_H_io


#define _Pantomime_H_io