Specifying outgoing UDP port?
-
Hello, I was wondering if it is possible to specify an OUTgoing port in a UDP connection. I already created and used a connection
SOCKET m_oUDPSocket;
SOCKADDR_IN m_oUDPAddress;.
.
.m_oUDPSocket = socket(AF_INET,SOCK_DGRAM,0);
memset(&m_oUDPAddress,0,sizeof(SOCKADDR_IN));
m_oUDPAddress.sin_family=AF_INET;
m_oUDPAddress.sin_port=htons(m_iClientPort);
m_oUDPAddress.sin_addr.s_addr=inet_addr(m_sClientIP.data());.
.
.int rc=sendto(m_oUDPSocket,(char*)packet,size+12,0,(SOCKADDR*)&m_oUDPAddress,sizeof(SOCKADDR_IN));
If I now wanted to make sure that my data is always sent FROM a certain port, how owuld I do that? Or how can I get the port from which it is actually sending (or has sent)? Regards Souldrift
-
Hello, I was wondering if it is possible to specify an OUTgoing port in a UDP connection. I already created and used a connection
SOCKET m_oUDPSocket;
SOCKADDR_IN m_oUDPAddress;.
.
.m_oUDPSocket = socket(AF_INET,SOCK_DGRAM,0);
memset(&m_oUDPAddress,0,sizeof(SOCKADDR_IN));
m_oUDPAddress.sin_family=AF_INET;
m_oUDPAddress.sin_port=htons(m_iClientPort);
m_oUDPAddress.sin_addr.s_addr=inet_addr(m_sClientIP.data());.
.
.int rc=sendto(m_oUDPSocket,(char*)packet,size+12,0,(SOCKADDR*)&m_oUDPAddress,sizeof(SOCKADDR_IN));
If I now wanted to make sure that my data is always sent FROM a certain port, how owuld I do that? Or how can I get the port from which it is actually sending (or has sent)? Regards Souldrift
have a look on it. A simple UDP time server and client for beginners[^] best of luck (Y)