Bluetooth QuickStart Kit Version 1.0 - User’s Guide Page 39
Copyright 2004-2005 © Embedded Artists AB
B.2.4 tcpListen
tS8 tcpListen( tTcpTcb* pTcb )
Set the control block in listen mode (i.e. server)
Parameters:
[in] pTcb - an allocated and bound TCB
Returns:
One of the error codes specified below.
Possible error situations (what can be identified in an error code):
TCP_OK - no error
TCP_LISTEN_ERROR - This error is returned if the control block wasn't in
CLOSED state when tcpListen was called
B.2.5 tcpAccept
void tcpAccept( tTcpTcb* pTcb, void (*pAcc)(tTcpTcb* pTcb) )
Registers an accept callback function. When a client attempts to connect to a TCB in
listen mode (a server socket) the accept callback function will be called. Supplied with
this accept call is the new control block for the established connection. It is this new
control block that should be used when sending and receiving data through the
connection.
Limitations to the number of accepted connections have to be controlled by the
application. The example below specifies how this can be done.
if(nbrOfConnections++ >= MAX_NBR_CONNECTIONS)
tcpClose(pTcb);
else
...
Parameters:
[in] pTcb - an allocated, bound TCB in LISTEN mode.
[in] pAcc - function pointer for the accept callback.
Parameters to (*pAcc):
[in] pTcb - control block for the established connection.
B.2.6 tcpReceive
void tcpReceive( tTcpTcb* pTcb, void (*pRecv)(tTcpTcb* pTcb,
tBuf* pBuf, tU16 len, tS8 err) )
This function registers a receive callback. The callback will be called whenever there is
received data on the established connection. Parameters to the callback function are the
control block for the connection, a pointer to the buffer containing the data, length of the
data and an error code.
Parameters:
[in] pTcb - a control block for an established connection.
[in] pRecv - function pointer to the receive callback.