Developer

API Reference

ISockPort_Connect()

Brew Release
Brew MP 1.0.2
See Also
None.
Description
For sockets of type AEE_SOCKPORT_STREAM, this attempts to initiate a TCP connection to the specified remote address.
AEE_AF_LOCAL: Currently AEE_AF_LOCAL is not supported.
AEE_AF_INET and AEE_AF_INET6: Prior to performing any socket-specific behavior, ISockPort_Connect() will try to acquire an IP address and ensure the underlying network layer is ready for communication. This may involve the establishment of an Internet connection using CDMA Packet Data or QNC if such a connection has not already been established. Finally, any previously-requested ISockPort_Bind() operation will be completed if necessary. As a result, errors relating to network startup or ISockPort_Bind() could be reported here.
Also note the possibility of an IPORT_WAIT result. This will normally occur only in cases where a network connection (e.g. a PPP link) must be established. In that event, Connect() will return IPORT_WAIT, and can be called again to obtain the final result (error or success). For notification of when to call Connect() again, the ISockPort_Writeable() call can be used. (Note that just as with Write(), a Writeable() callback does not guarantee that a subsequent call to Connect() call will complete, so the caller must be prepared to receive IPORT_WAIT again.)
Parameters
  • po
    []:
    pointer to the ISockPort interface
  • pAddr
    []:
    an opaque pointer to the address to connect to (see AEESockAddrStorage)
Interface
Prototype
   int ISockPort_Connect(ISockPort* po, const void* pAddr)
Return
AEE_SUCCESS: socket has been successfully connected to the remote address
IPORT_WAIT: (AEE_AF_INET and AEE_AF_INET6 only) The operation cannot be completed at present. This can occur when a network connection is being established (see ISockPort_Writeable()).
AEE_NET_EBADF : socket is not open AEE_NET_EAFNOSUPPORT : not an inet address AEE_NET_EMFILE : not enough resources to complete this operation (too many sockets in use) AEE_NET_ENETDOWN : network subsystem is unavailable (e.g. handset is outside of coverage area) AEE_NET_ECONNREFUSED : connection attempt refused AEE_NET_ETIMEDOUT : connection attempt timed out AEE_NET_EFAULT : invalid address parameter has been specified AEE_NET_EOPNOTSUPP : invalid server address specified, or not a stream socket AEE_NET_EISCONN : socket is already connected AEE_NET_ENOMEM : not enough memory to establish connection. AEE_NET_EIPADDRCHANGED: IP address changed due to PPP resync AEE_NET_EINPROGRESS : connection establishment in progress AEE_NET_ENETNONET : network subsystem unavailable
The following error codes can be returned for a stream socket in case the AEE_SO_ERROR_ENABLE socket option is enabled and there is a pending ICMP error for the socket:
AEE_NET_ENETUNREACH : network is unreachable AEE_NET_EHOSTUNREACH : host is unreachable AEE_NET_EHOSTDOWN : host is down AEE_NET_ENONET : host is not on the network AEE_NET_EPROTO : protocol error AEE_NET_EACCES : access denied AEE_NET_ENOPROTOOPT : protocol unreachable AEE_NET_EMSGSIZE : message too large
Other error codes are also possible.
Side Effect
None.
Comment
Note that the IPORT_WAIT return value is used instead of an error return value and an AEE_NET_EWOULDBLOCK error code.
ISockPort_Connect() with DGRAM sockets is not supported.
  • Follow