TCPAccept[Async]


C Specification

#include <dolphin/ip.h>

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

s32 TCPAccept     ( TCPInfo* info, TCPInfo* listening );

s32 TCPAcceptAsync( TCPInfo* info, TCPInfo* listening,
                    TCPCallback callback, s32* result );

Description

TCPAcceptAsync() accepts an incoming connection request to the listening socket. The TCPInfo listening must be the listening TCPInfo set with TCPListen().

The callback function is called when the connection is established, or when an error is detected. If the info state is TCP_STATE_ESTABLISHED or TCP_STATE_CLOSE_WAIT, the remote host might have sent some data to the local host. The the state of info can be checked with TCPGetStatus(). 

Arguments

info Pointer to a TCPInfo that establishes the connection.
listening Pointer to a TCPInfo that is listening to a connection request.
callback Informed when a connection is established.
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_EXIST Connection already exists.
IP_ERR_NOT_EXIST Invalid listening TCPInfo.
IP_ERR_INVALID info is not a valid TCPInfo.

Callback specific result values

IP_ERR_REFUSED Connection refused. The connection is reset in the middle of three-way hand shake.
IP_ERR_RESET Connection reset
IP_ERR_CLOSING Connection closing.

See Also

TCPListen(), TCPGetStatus()