getting upload and download bandwidth

This is a discussion on getting upload and download bandwidth within the C++ Programming forums, part of the General Programming Boards category; i am doing a prog to check the upload and download bandwidth of my computer currently in use 1. i ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    getting upload and download bandwidth

    i am doing a prog to check the upload and download bandwidth of my computer currently in use

    1. i want them to be separate data,upload : 56kb/s, download: 43kb/s. not the sum of the bandwidth together

    2. if possible , also separate LAN and internet bandwidth, this is quite hard, i think it involves determining whether the connection is local or internet and sort them out according. or is there a api that does the job

    3. number of connections established

    anybody knows of any APIs to do the job?
    Last edited by hanhao; 03-15-2004 at 05:26 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    You neglected to mention which OS/Compiler you have to perform all this magic.

    But if you're on Linux, then the netstat program does pretty much what you ask.
    Since you can get the source code for that, I'd start there for inspiration.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    114
    using win98

  4. #4
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    hmmm

    this is barely related to this topic, but when you are using a system(variable); command, where variable is something like 'ping 192.34.0.0' how do you get the information it returns to the screen?

    do you use something like strcpy(returnedvalue, system(variable)); ?
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >how do you get the information it returns to the screen?
    You don't use the system function. You pipe the output from the program in question to your program. The system function returns an int, implementation defined if the argument is not a null pointer.
    My best code is written with the delete key.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    Say

    Code:
    char buff[BUFSIZ];
    FILE *fp = popen( "ping www.google.com", "r" );
    while ( fgets( buff, sizeof buff, fp ) != NULL ) {
      // do stuff with a line of output from ping
    }
    pclose( fp );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    wow

    im afraid your answer is completely over my head...

    your sample code is writing what the system returns into a file? im so confused just by your syntax.
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    Here's an idea.
    Copy the code into your IDE, put the cursor over each bit you don't understand and press F1 for help.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    But F1 doesn't work in emacs...
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  10. #10
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    >But F1 doesn't work in emacs.
    He's on win98 not Linux.

    Also, what compiler are you using?

    I'll search some for this..
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  11. #11
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >>He's on win98 not Linux.
    Emacs is available for Windows 98.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  12. #12
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169
    err hello again tronic, nice to see such a friendly person such as yourself again...

    anyway tho im on xp... i sorta took over this thread as the author seemingly abandoned it. i guess i shoulda been more specific in my questioning tho. what libs and linkages do i need for that code fragment? im getting the compilation errors below.

    error C2065: 'popen' : undeclared identifier

    error C2440: 'initializing' : cannot convert from 'int' to 'struct _iobuf *'Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

    error C2065: 'pclose' : undeclared identifier
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

  13. #13
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    Gak!
    Damn windows doing just enough to try to be POSIX whilst annoying everyone at the same time
    Try
    _popen
    _pclose

    Go figure...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Registered User Nova_Collision's Avatar
    Join Date
    Feb 2003
    Posts
    40
    Hey, I was linked to this thread from wanting to get the java version. I understand MOST of that :P Sorta....anyway, obviously not enough because the program crashes whenever I try to run that code block. Here is what I tried :

    Code:
    	char buff[50];
    	FILE *fp = _popen("java -version", "r");
    	while(fgets(buff, sizeof buff, fp) != NULL) 
    	{
    		MessageBox(NULL, buff, "Java Return", MB_OK);
    	}
    	_pclose(fp);
    	return 0;
    Also, part of this is determining whether or not they have java installed at all. Will the stream return "Bad Command Or File Name" as it does at command line or will it cause problems if "java.exe" doesn't exists?
    When in doubt, empty your magazine - Murphy's Laws Of Combat #7

  15. #15
    Registered User Nova_Collision's Avatar
    Join Date
    Feb 2003
    Posts
    40
    More specific : The code caused an assertion failure, which I have no idea how to handle.
    When in doubt, empty your magazine - Murphy's Laws Of Combat #7

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. upload / download speeds
    By Dino in forum Tech Board
    Replies: 20
    Last Post: 11-25-2008, 08:06 PM
  2. BitTorrent download rate oscillating strangely
    By brewbuck in forum Tech Board
    Replies: 4
    Last Post: 04-29-2007, 10:35 PM
  3. using the upload
    By iain in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 08-19-2001, 11:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21