How to send a packet via a UDP CFSocket?

前端 未结 2 661
遇见更好的自我
遇见更好的自我 2021-01-02 11:29

I am a complete newbie to networking, however I am a c/c++ programmer, and am working in objective-c (This is for OSX/iPhone).

I am trying to learn how to send a mag

2条回答
  •  执笔经年
    2021-01-02 12:14

    Your problem is very simple: you are not telling the CFSocket where you want it to send the data.

    You carefully construct an address in addr, but then don't use it. You either need to call CFSocketSetAddress to set the destination address on the socket (if you want all packets you send to go to the same destination), or pass the address as the 2nd argument to CFSocketSendData.

提交回复
热议问题