• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to set destination address on UDP?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to set destination address on UDP?


  • Subject: How to set destination address on UDP?
  • From: "peiyuan" <email@hidden>
  • Date: Thu, 6 Sep 2007 17:56:00 +0800

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


  • Follow-Ups:
    • Re: How to set destination address on UDP?
      • From: Josh Graessley <email@hidden>
  • Next by Date: Re: How to set destination address on UDP?
  • Next by thread: Re: How to set destination address on UDP?
  • Index(es):
    • Date
    • Thread