|
Defines | |
| #define | MAX_SENDFILE_CHUNK_SIZE (64 * 1024) |
| #define | MAX_SAVEINTOFILE_CHUNK_SIZE (64 * 1024) |
Functions | |
| int | qSocketOpen (const char *hostname, int port) |
| Create a TCP socket for the remote host and port. | |
| bool | qSocketClose (int sockfd) |
| Close socket. | |
| int | qSocketWaitReadable (int sockfd, int timeoutms) |
| Wait until the socket has some readable data. | |
| int | qSocketWaitWritable (int sockfd, int timeoutms) |
| Wait until the socket is writable. | |
| ssize_t | qSocketRead (void *binary, int sockfd, size_t nbytes, int timeoutms) |
| Read data from socket. | |
| ssize_t | qSocketGets (char *str, int sockfd, size_t nbytes, int timeoutms) |
| Read line from the stream. | |
| ssize_t | qSocketWrite (int sockfd, const void *binary, size_t nbytes) |
| Send string or binary data to socket. | |
| ssize_t | qSocketPuts (int sockfd, const char *str) |
| Send string with newline characters(CRLF) to socket. | |
| ssize_t | qSocketPrintf (int sockfd, const char *format,...) |
| Send formatted string to socket. | |
| ssize_t | qSocketSendfile (int sockfd, const char *filepath, off_t offset, size_t nbytes) |
| Send file to socket. | |
| ssize_t | qSocketSaveIntoFile (int filefd, int sockfd, size_t nbytes, int timeoutms) |
| Store socket data into file directly. | |
| ssize_t | qSocketSaveIntoMemory (char *mem, int sockfd, size_t nbytes, int timeoutms) |
| Store socket data into memory directly. | |
| int qSocketOpen | ( | const char * | hostname, | |
| int | port | |||
| ) |
Create a TCP socket for the remote host and port.
| hostname | remote hostname | |
| port | remote port |
| bool qSocketClose | ( | int | sockfd | ) |
Close socket.
| sockfd | socket descriptor |
| int qSocketWaitReadable | ( | int | sockfd, | |
| int | timeoutms | |||
| ) |
Wait until the socket has some readable data.
| sockfd | socket descriptor | |
| timeoutms | wait timeout milliseconds. if set to negative value, wait indefinitely. |
| int qSocketWaitWritable | ( | int | sockfd, | |
| int | timeoutms | |||
| ) |
Wait until the socket is writable.
| sockfd | socket descriptor | |
| timeoutms | wait timeout mili-seconds. if set to negative value, wait indefinitely. |
| ssize_t qSocketRead | ( | void * | binary, | |
| int | sockfd, | |||
| size_t | nbytes, | |||
| int | timeoutms | |||
| ) |
Read data from socket.
| binary | data buffer pointer | |
| sockfd | socket descriptor | |
| nbytes | read size | |
| timeoutms | wait timeout milliseconds |
| ssize_t qSocketGets | ( | char * | str, | |
| int | sockfd, | |||
| size_t | nbytes, | |||
| int | timeoutms | |||
| ) |
Read line from the stream.
New-line characters(CR, LF ) will not be stored into buffer.
| str | data buffer pointer | |
| sockfd | socket descriptor | |
| nbytes | read size | |
| timeoutms | wait timeout milliseconds |
| ssize_t qSocketWrite | ( | int | sockfd, | |
| const void * | binary, | |||
| size_t | nbytes | |||
| ) |
Send string or binary data to socket.
| sockfd | socket descriptor | |
| binary | data pointer | |
| nbytes | sending size |
| ssize_t qSocketPuts | ( | int | sockfd, | |
| const char * | str | |||
| ) |
Send string with newline characters(CRLF) to socket.
| sockfd | socket descriptor | |
| str | string pointer |
| ssize_t qSocketPrintf | ( | int | sockfd, | |
| const char * | format, | |||
| ... | ||||
| ) |
Send formatted string to socket.
| sockfd | socket descriptor | |
| format | variable argument lists |
| ssize_t qSocketSendfile | ( | int | sockfd, | |
| const char * | filepath, | |||
| off_t | offset, | |||
| size_t | nbytes | |||
| ) |
Send file to socket.
| sockfd | socket descriptor | |
| filepath | variable argument lists | |
| offset | file start to send | |
| nbytes | total bytes to send. 0 means send data until EOF. |
| ssize_t qSocketSaveIntoFile | ( | int | filefd, | |
| int | sockfd, | |||
| size_t | nbytes, | |||
| int | timeoutms | |||
| ) |
Store socket data into file directly.
| filefd | save file descriptor | |
| sockfd | socket descriptor | |
| nbytes | length of bytes to read from socket | |
| timeoutms | wait timeout milliseconds |
qSocketSaveIntoFile(filefd, sockfd, 100, 5000);
| ssize_t qSocketSaveIntoMemory | ( | char * | mem, | |
| int | sockfd, | |||
| size_t | nbytes, | |||
| int | timeoutms | |||
| ) |
Store socket data into memory directly.
| mem | memory buffer pointer | |
| sockfd | socket descriptor | |
| nbytes | length of bytes to read from socket | |
| timeoutms | wait timeout milliseconds |
| [Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference] |