Hello , im sending a message "teste" by udp socket, i would like to add a sequence number at teste like:
teste1
teste2
teste3
teste4 and so on....
i got this peace of code:
Code:
#define HELLO_PORT 12345
#define HELLO_GROUP "192.168.0.1"
int main(int argc, char *argv[])
{
struct sockaddr_in addr;
int fd;
char *message = "teste";
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror("socket");
exit(1);
}
/* set up destination address */
memset(&addr,0,sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr(HELLO_GROUP);
addr.sin_port=htons(HELLO_PORT);
while (1)
{
if (sendto(fd, message, strlen(message), 0,(struct sockaddr *) &addr, sizeof(addr)) < 0)
{
perror("sendto");
exit(1);
}
sleep(2);
}
}
many thanks