@CHIP-RTOS C Library - TCP/IP API
RegisterCallbackFunction
Register a TCP user callback function. int RegisterCallbackFunction ( int sd,
void far *funcptr,
int eventflagmask,
int *error ); Parameters
sd
- Socket descriptor.
funcptr
- Pointer to user's callback function.
eventflagmask
- Event flag mask bit field (see menu below)
error
- Output parameter: Failure
code, 0 on success.
Return Value
- 0 = success
Non-zero = Failure (see error
output parameter)
Comments
- The events which trigger the callback are controlled with the
eventflagmask
input parameter. The set of possible
event flags are (defined in TCPIPAPI.H):
- CB_CONNECT_COMPLT - connection complete
- CB_ACCEPT - remote has established a connection to our listening server
- CB_RECV - incoming data arrived
- CB_SEND_COMPLT - sending of data has been acknowledged by the peer
- CB_REMOTE_CLOSE - peer has shut down the connection
- CB_SOCKET_ERROR - an error occured on the connection
- CB_RESET - peer has sent a rest on the connection
- CB_CLOSE_COMPLT - close has been completed
These flags can be OR'ed together to form the mask for the set of events
at which you want to be called.
The callback function should satisfy the following prototype (Borland C):
void huge socketCallBackFunc(int socketdescriptor,
int eventFlags) ;
The callback function's parameter eventFlags
contains the event(s)
that have occured. This bit field is encoded the same as the
eventflagmask
input parameter to this API function.
Note that most of the call back calls will be made in the context of the drivers
receive task (e.g. task ETH0). Therefore processing should be kept at a minimum in the
call back function. The user call back function should set a flag or increase a counter and
signal the user application task.
A socket callback may be removed by calling this API function with
both a null funcptr
and zero eventflagmask
.
Closing the socket also deactivates
the callback.
Before exiting a program, any sockets which have callbacks installed must either
be closed or have the callback removed. Otherwise a callback could be present
which references a program no longer loaded into memory.
See Also
RTOS API
- This library function invokes a RTOS software interrupt.
Refer to this RTOS API function's
documentation
for more details.
Supported since or modified in @CHIP-RTOS version-
| SC12 | SC13 | SC11 | SC1x3 | SC2x |
-
| V1.00 | V1.00 | V1.00 | V0.90 | V1.00 |
This API List
List of C Libraries
@CHIP-RTOS Main Index
End of document
|