tfHttpcUserConnect
Table of Contents >> Application Reference >> Web Client
#include <trsocket.h> |
int tfHttpcUserConnect | ( |
ttHttpcUserConHandle conHandle, | |
const struct sockaddr_storage * sockAddrPtr, | |
int flags | |
); |
Function Description
Try to connect to the specified HTTP server In non-blocking mode, when TM_EINPROGRESS is returned, the user has two choices:
- Call this API again and again(polling mode) until it returns TM_ENOERROR indicating the establishment of the connection, or until an error occurs.
- Call tfHttpcUserExecute() periodically and wait for the event handler to be notified with TM_HTTPC_EVENT_CONNECTED or TM_HTTPC_EVENT_FAILED_TO_CONNECT. Note that this approach would work only if the user has provided a non-NULL event handler to tfHttpcUserOpen().
Parameters
- conHandle
- HTTP client connection handle
- sockAddrPtr
- Pointer to the socket address specifying the protocol family, IP address and port number of the HTTP server to connect to.
- flags
- ORable flags:
- TM_BLOCKING_ON, blocking mode
- TM_BLOCKING_OFF, non-blocking mode
Returns
- TM_ENOERROR
- Successful
- TM_EISCONN
- The connection has already established
- TM_EBADF
- The socket descriptor is invalid
- TM_EINPROGRESS
- The socket is non-blocking and the current connection attempt has not yet been completed.
- TM_EINVAL
- One or more of the parameters is invalid
- TM_EADDRINUSE
- The socket address is already in use.
- TM_EADDRNOTAVAIL
- The specified address is not available on the remote / local machine
- TM_ECONNREFUSED
- The attempt to connect was forcefully rejected. User should close this connection before trying to connect to this server again
- TM_EHOSTUNREACH
- No route to the host we want to connect to. User should close this connection before trying to connect to this server again
- TM_ETIMEDOUT
- Connection establishment timed out, without establishing a connection. User may choose to try again or close the connection.
- TM_EAFNOSUPPORT
- Address family cannot be used with this socket