[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


UDP sendto() function allows you to mention the destination...

<< Back to: [comp.unix.programmer] Unix-socket-faq for network programming

Question by santhosh
Submitted on 12/8/2003
Related FAQ: [comp.unix.programmer] Unix-socket-faq for network programming
Rating: Not yet rated Rate this question: Vote
UDP sendto() function allows you to mention the destination ip and port to which you want to send data. But I wanted to specify the source port also.
for example,
I want to send some data to (a server)"192.168.14.56:5062" from the client using the port 5060.
(Data should go from the port 5060 of my system to the port 5062 of other system)



Answer by socket_newbie
Submitted on 2/13/2005
Rating: Not yet rated Rate this answer: Vote
Using TCP you could specify this information. UDP does not maintain the information of who is sending data.

 

Answer by Chunsheng Guo
Submitted on 3/16/2005
Rating: Not yet rated Rate this answer: Vote
When you call sendto(handler, IP_addr, buf, len), handler contains your local source address information.
Handler value is assigned when you open a sock and bind.

 

Answer by Isa Muqattash
Submitted on 11/24/2005
Rating: Not yet rated Rate this answer: Vote
You can simply append the source port number to the data sent within the packet, and then have the receiver extract this info

 

Answer by Adam
Submitted on 12/5/2005
Rating: Not yet rated Rate this answer: Vote
You need to bind() the socket with the source port address. Then use sendto() with the destination address.

 

Answer by Wolfgang Jia
Submitted on 1/3/2006
Rating: Not yet rated Rate this answer: Vote
Bind the socket to certain address and port before send any data. If you want to send and receive by the same port, use the receiving socket to send the data.

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: [comp.unix.programmer] Unix-socket-faq for network programming


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.