Sending packets using an specific port
-
Hi, is it any way I can send a packet using an specific port?, for example, what would I have to do if I want to send a packet using the source port xxxx? Thx in advance Vertigo Real Programmer isn't who just knows how to use a programming tool, Real Programmer is who knows how to write cool stuff in any language, 'cuz he/she/(it!!?) thinks like a machine :cool:.
-
Hi, is it any way I can send a packet using an specific port?, for example, what would I have to do if I want to send a packet using the source port xxxx? Thx in advance Vertigo Real Programmer isn't who just knows how to use a programming tool, Real Programmer is who knows how to write cool stuff in any language, 'cuz he/she/(it!!?) thinks like a machine :cool:.
BOOL fBroadcast = TRUE; int err = setsockopt(*lpSock, SOL_SOCKET, SO_BROADCAST, (CHAR *)&fBroadcast , sizeof(BOOL) ); sock.sin_family = PF_INET; sock.sin_addr.s_addr = htonl(INADDR_ANY); sock.sin_port = htons((u_short)wHostPort); if (bind(*lpSock,(LPSOCKADDR)&sock,sizeof(sock)) != SOCKET_ERROR) nRet = ENOERROR;
You don't normally need to send from a specific port (although this isn't always true) - here's an example of how it is done. wHostPort is the port number that would be used to send from (source port).