Developer

API Reference

ISOCKET_Connect()

Brew Release
Brew MP 1.0.2
Description
For sockets of type AEE_SOCK_STREAM, this attempts to initiate a TCP connection to the specified address and port.
Prior to performing any socket-specific behavior, ISOCKET_Connect() will perform an ISOCKET_Realize() if necessary.
After establishment of a connection to the Internet, the callback is passed the error code that describes how the connect operation completed. As with all network callbacks, the callback is called within the same thread context, at some point in time after the caller returns control to the AEE event loop.
Parameters
  • pISocket
    []:
    Pointer to the ISocket Interface object.
  • a
    []:
    IP Address.
  • wPort
    []:
    Port.
  • pfn
    []:
    Address of the callback function that is invoked by AEE when the connect operation either succeeds or fails.
  • pUser
    []:
    User-defined data that is passed to the callback function when it is invoked.
Interface
ISOCKET
Prototype
    int ISOCKET_Connect
    (
    ISocket * pISocket,
    INAddr a,
    INPort wPort,
    PFNCONNECTCB pfn,
    void * pUser
    )
Return
AEE_NET_SUCCESS: if successful. This indicates that the callback will be called after the caller relinquishes control.
AEE_NET_ERROR: when a NULL callback pointer (pfn) was passed. This is the only case in which the callback will not be called.
Side Effect
None.
Comment
The registered callback can be cancelled (un-registered) with ISOCKET_Cancel().
The INAddr and INPort arguments are assumed to be in network byte order (for example, big-endian). This issue is important for portability across simulator environments and potential device targets. The callback is passed one of the following values describing the completion of the connect operation:
AEE_NET_EADDRINUSE
Local address requested via a prior call to ISOCKET_Bind() was not available.
AEE_NET_EBADF
Invalid socket descriptor is specfied
AEE_NET_ECONNREFUSED
Connection attempt refused
AEE_NET_EIPADDRCHANGED
IP address changed due to PPP resync
AEE_NET_EINVAL
Invalid IP address and/or port specified
AEE_NET_EISCONN
The socket is already connected (result was already received by a previous call to Connect())
AEE_NET_EMFILE
Not enough network resources to complete this operations (too many sockets in use). AEE_NET_ENETDOWN
Network is not available (e.g. handset outside of coverage area)
AEE_NET_EOPNOTSUPP
Socket type is not STREAM.
AEE_NET_ETIMEDOUT
Connection attempt timed out
AEE_NET_SUCCESS
Connect completed successfully; socket is prepared for reading and/or writing.
  • Follow