MOBFUDPClient.h 889 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // MOBUDPClient.h
  3. // RTSPDemo
  4. //
  5. // Created by fenghj on 16/4/8.
  6. // Copyright © 2016年 vimfung. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /**
  10. * 接收数据回调处理器
  11. */
  12. typedef void (^MOBFUDPClientReceiveDataHandler) (NSString *address, UInt32 port, NSData *data);
  13. /**
  14. * UDP客户端
  15. */
  16. @interface MOBFUDPClient : NSObject
  17. /**
  18. * 初始化UDP客户端
  19. *
  20. * @param port 端口
  21. *
  22. * @return 客户端对象
  23. */
  24. - (instancetype)initWithPort:(UInt32)port;
  25. /**
  26. * 开始
  27. */
  28. - (void)start;
  29. /**
  30. * 结束
  31. */
  32. - (void)stop;
  33. /**
  34. * 发送数据
  35. *
  36. * @param data 数据
  37. * @param address 地址
  38. * @param port 端口
  39. */
  40. - (void)sendData:(NSData *)data toAddress:(NSString *)address andPort:(UInt32)port;
  41. /**
  42. * 接收到数据
  43. *
  44. * @param handler 事件处理器
  45. */
  46. - (void)onReceiveData:(MOBFUDPClientReceiveDataHandler)handler;
  47. @end