Computing.Net > Forums > Programming > UDP source port in C

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

UDP source port in C

Reply to Message Icon

Name: kallor
Date: April 17, 2008 at 02:18:49 Pacific
OS: linux 2.6.24
CPU/Ram: -
Product: -
Comment:

Hi.
Im sending data over a SOCK_DGRAM socket, is it possible to define what source port my program will use?
I guess one alternative is to craft the UDP header by myself, what type of socket would I use then? Do I have to craft the IP header aswell and use SOCK_RAW?

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: kallor
Date: April 17, 2008 at 05:41:53 Pacific
Reply:

Nevermind.
from newsgroups:

> Yes - just set the sin_port field of the struct sockaddr *address
> argument you give to bind(). (The default value of 0 for sin_port just
> means "pick any available port".)


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: UDP source port in C

how to program for serial port in C www.computing.net/answers/programming/how-to-program-for-serial-port-in-c/8494.html

Programming parallel port in C, linux www.computing.net/answers/programming/programming-parallel-port-in-c-linux-/2795.html

Need help with CRC in C Lanquage. www.computing.net/answers/programming/need-help-with-crc-in-c-lanquage/9678.html