UDP bind to define which source port to use

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marco712
    New Member
    • Jun 2013
    • 1

    UDP bind to define which source port to use

    Hi. I am trying to define which source port my program will use to send a packet from. I am able to define which port to send to, but not from. I'm sure it is possible but I don't know what exactly to do.

    Here is what I have on my program:

    Code:
    		sin.sin_addr.s_addr = *(LPDWORD)gethostbyname((char *)s_uf.m_szHost)->h_addr_list[0];
    		sin.sin_family = AF_INET;
    		sin.sin_port = htons(s_uf.m_nPort);
    		sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    	if (sock == SOCKET_ERROR)
    The "sin.sin_addr.s _addr" is so I can define which address to send the packet to and "sin.sin_po rt" is for me to define which port I can send the packet to.

    Can someone please give me a code I can use so I can define which source port I can use to send packet from? I have the .cpp if anyone needs it.

    Thanks
    Last edited by Rabbit; Jun 24 '13, 05:10 PM. Reason: Please use code tags when posting code or formatted data.
Working...