June 24th, 2013, 10:52 AM
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:
sin.sin_addr.s_addr = *(LPDWORD)gethostbyname((char *)s_uf.m_szHost)->h_addr_list;
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_port" 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.
Last edited by marco712; June 24th, 2013 at 10:59 AM.
Click Here to Expand Forum to Full Width