• 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
Re: How to set destination address on UDP?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set destination address on UDP?


  • Subject: Re: How to set destination address on UDP?
  • From: "peiyuan" <email@hidden>
  • Date: Fri, 7 Sep 2007 17:35:36 +0800

Hi Josh,

Thank you a lot......It WORKS........

Thanks again.

Pei-Yuan

----- Original Message ----- From: "Josh Graessley" <email@hidden>
To: "peiyuan" <email@hidden>
Cc: <email@hidden>
Sent: Thursday, September 06, 2007 11:18 PM
Subject: Re: How to set destination address on UDP?




Look for the msg versions of the send and receive functions. Those let you receive the senders address and specify the destination when sending.


Sent from my iPhone

On Sep 6, 2007, at 2:56, peiyuan <email@hidden> wrote:

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

_______________________________________________ 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
References: 
 >How to set destination address on UDP? (From: "peiyuan" <email@hidden>)
 >Re: How to set destination address on UDP? (From: Josh Graessley <email@hidden>)

  • Prev by Date: Re: Socket timeout issue
  • Next by Date: Re: Socket timeout issue
  • Previous by thread: Re: How to set destination address on UDP?
  • Next by thread: Socket timeout issue
  • Index(es):
    • Date
    • Thread