Hello all,
I am trying to build an echo server using UDP(NKE). Main codes are
listed below:
---
---
---
---
-------------------------------------------------------------------
start
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons((short)port);
sin.sin_len = sizeof(sin);
sock_socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP, (sock_upcall)
&sock_create_callback, (void*)cookie, &so);
sock_setsockopt(so,SOL_SOCKET,SO_REUSEADDR, &on,sizeof(on));
sock_bind(so, (struct sockaddr*)&sin);
sock_receivembuf(so, NULL, &data_in, MSG_DONTWAIT, &len);
{
...................................
}
sock_sendmbuf(so, NULL, data_out, MSG_DONTWAIT, &len);
---
---
---
---
-------------------------------------------------------------------end
I can receive the data sent by client but however I can't send data back
to the client. The error code says that destination address required.
In TCP, I can read source address through sock_accept function. But in
UDP, there is no such things as accept. So what function should I use
to set the destination address(ip&port).
I'd be appreciated if someone could help me. Thank you.
Pei-Yuan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden