Thanks for your reply. I am a beginer of libuv.
I want to use port 6883(it's just a example) send a message, so i use
uv_udp_bind but get an "Invalid argument" error. Could you help me figure
out where i am wrong . Thanks a lot : )
uv_udp_init(loop, &sendSocket);
uv_ip4_addr(ipv4.c_str(), port, &sendAddr);
uv_buf_t buffer = uv_buf_init((char *)msg.c_str(), (unsigned
int)msg.length());
struct sockaddr_in temp;
uv_ip4_addr("127.0.0.1", 6883, &temp);
uv_udp_bind(&sendSocket, (const struct sockaddr*)&temp, 0);
perror("here");
int error = uv_udp_send(&sendRequest, &sendSocket, &buffer, 1,
(const struct sockaddr *)&sendAddr, send_callback);
On Tuesday, February 2, 2016 at 7:09:07 PM UTC+8, 翟帅 wrote:
>
> How to set the source port in the UDP socket in libuv?
> <http://stackoverflow.com/questions/9873061/how-to-set-the-source-port-in-the-udp-socket-in-c>
>
--
You received this message because you are subscribed to the Google Groups
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.