libcm is a C development framework with an emphasis on audio signal processing applications.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cmRtNet.h 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef cmNet_h
  2. #define cmNet_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkNetRC = cmOkRC,
  9. kUdpPortFailNetRC,
  10. kInvalidLabelNetRC,
  11. kDuplLabelNetRC,
  12. kDuplLocalNetRC,
  13. kDuplEndNetRC,
  14. kThreadFailNetRC,
  15. kBufToSmallNetRC,
  16. kNodeNotFoundNetRC,
  17. kNodeStateErrNetRC,
  18. kTimeOutErrNetRC,
  19. kLocalNodeNetRC,
  20. };
  21. typedef cmRC_t cmRtNetRC_t;
  22. typedef cmHandle_t cmRtNetH_t;
  23. extern cmRtNetH_t cmRtNetNullHandle;
  24. // 'cbFunc' will be called within the context of cmRtNetReceive() to receive
  25. // incoming network messages.
  26. cmRtNetRC_t cmRtNetAlloc( cmCtx_t* ctx, cmRtNetH_t* hp, cmUdpCallback_t cbFunc, void* cbArg );
  27. cmRtNetRC_t cmRtNetFree( cmRtNetH_t* hp );
  28. bool cmRtNetIsValid( cmRtNetH_t h );
  29. // Create a network node.
  30. // The 'nodeLabel' refers to a network device cfg. (see cmDevCfg).
  31. // Set 'ipAddr' to NULL if this is the local node.
  32. // During sync mode this node will attempt to sync with all
  33. // nodes in the node list.
  34. cmRtNetRC_t cmRtNetCreateNode( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* ipAddr, cmUdpPort_t ipPort );
  35. // Register the local endpoints.
  36. // Remote nodes will be able to send messages to these endpoints by
  37. // referring to (nodeLabel/endPtLabel)
  38. cmRtNetRC_t cmRtNetRegisterEndPoint( cmRtNetH_t h, const cmChar_t* endPtLabel, unsigned endPtId );
  39. // Delete all nodes and endpoints.
  40. cmRtNetRC_t cmRtNetClearAll( cmRtNetH_t h );
  41. // Go into 'sync' node.
  42. // When a node enters sync mode it systematically transmits all of it's local endpoint
  43. // information to each registered remote node. Prior to entering sync mode a node
  44. // must therefore have been setup with a list of remote nodes (via cmRtNetCreateNode())
  45. // and a list of local endpoints (cmRtNetRegisterEndpoint()).
  46. // During sync mode a node sends it's local endpoint list to each registered remote node.
  47. // When a remote node receives an endpoint it updates it's own remote node/endpoint
  48. // list.
  49. cmRtNetRC_t cmRtNetBeginSyncMode( cmRtNetH_t h );
  50. bool cmRtNetIsInSyncMode( cmRtNetH_t h );
  51. // When the network message recieve function (See cmRtNetAlloc() 'cbFunc')
  52. // receives a message with the cmRtSysMsgHdr_t.selId == kNetSyncSelRtId
  53. // it should call this function to update the current sync state of the
  54. // cmRtNet.
  55. cmRtNetRC_t cmRtNetSyncModeRecv( cmRtNetH_t h, const char* data, unsigned dataByteCnt, const struct sockaddr_in* fromAddr );
  56. // When in the network is in sync mode (cmRtNetIsSync()==true)
  57. // the client system must poll this function to update the networks sync state.
  58. cmRtNetRC_t cmRtNetSyncModeSend( cmRtNetH_t h );
  59. // This function must be polled to receive incoming network messages
  60. // via the callback funcion 'cbFunc' as passed to cmRtNetAlloc()
  61. cmRtNetRC_t cmRtNetReceive( cmRtNetH_t h );
  62. unsigned cmRtNetEndPointIndex( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* endPtLabel );
  63. cmRtNetRC_t cmRtNetSend( cmRtNetH_t h, unsigned endPointIndex, const void* msg, unsigned msgByteCnt );
  64. void cmRtNetReport( cmRtNetH_t h );
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif