TCPConnect[Async]


C Specification

#include <dolphin/ip.h>

typedef void (* TCPCallback )(TCPInfo* info, s32 result);

typedef struct IPSocket
{
     u8 len; // IP_SOCKLEN
     u8 family; // IP_INET
     u16 port;
     u8 addr[IP_ALEN];
} IPSocket;

s32 TCPConnect     ( TCPInfo* info, const IPSocket* socket );

s32 TCPConnectAsync( TCPInfo* info, const IPSocket* socket,
                     TCPCallback callback, s32* result );

Description

TCPConnectAsync() attempts to make a connection to the remote socket. If the local socket has not been specified with TCPBind(), an ephemeral local socket will be automatically chosen between 1024 and 5000.

Note: You do not have to wait for the completion of the connection establishment before start sending data to the other end of the connection with TCPSendAsync().

Arguments

info TCP info to which assign the remote socket.
socket A pair of IP address and TCP port number.
callback Optional. Notified when the connection is established or is failed.
result Optional pointer to s32 that receives the function result. While the operation is in progress, the value *result  is set to IP_ERR_BUSY.

Return Values

IP_ERR_NONE Succeeded.
IP_ERR_AGAIN Connection is being established asynchronously.
IP_ERR_INV_SOCKET Specified socket address is not valid.
IP_ERR_UNREACHABLE Specified socket is unreachable from this machine.
IP_ERR_EXIST Specified socket is already in use.
IP_ERR_INVALID info is not a valid TCPInfo. Specified socket is not valid.
IP_ERR_INS_RESOURCES Used up ephemeral local ports.
IP_ERR_NETDOWN Local network interface is down.

Callback specific result values

IP_ERR_CLOSING Connection closing.
IP_ERR_RESET Connection reset
IP_ERR_REFUSED Connection refused
IP_ERR_TIMEOUT Connection timeout

See Also

TCPBind(),  TCPSendAsync(), IPSocket