Thread: getting upload and download bandwidth

  1. #16
    Registered User Nova_Collision's Avatar
    Join Date
    Feb 2003
    Posts
    40
    :P Perhaps I should research more before I post. Anyway, here's where I'm at. I figured out what an Assertion failure is, but the _popen example (THE EXAMPLE!!) in MSVS 6 generates an error itself. Which makes me wonder.....

    Anyway, I've stepped through and as far as I can tell, there is no way for this code to not generate an error. It tries to use a variable in fgets.c (FILE *str) in a check (_ASSERTE(str != null)) without ever initialising str to anything. That's what I understand from the code, anyway.

    Is there any other way for me to get what "java -version" returns at command line in my program?
    When in doubt, empty your magazine - Murphy's Laws Of Combat #7

  2. #17
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > fgets.c (FILE *str) in a check (_ASSERTE(str != null))
    Yeah, it means the popen() failed.

    Code:
    FILE *fp = _popen("java -version", "r");
    if ( fp == NULL ) {
      perror( "Gotta problem" );
    } else {
      // rest of your code
    }
    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.

  3. #18
    Registered User Nova_Collision's Avatar
    Join Date
    Feb 2003
    Posts
    40
    Okaaayyyyy......so what do I do? No matter what I try, the _popen fails. Every time. Example code included. Does that mean I can't check the output of command line executions?
    When in doubt, empty your magazine - Murphy's Laws Of Combat #7

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I dunno, does the perror() message actually tell you anything useful, like "why" it could not be completed?
    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.

  5. #20
    Registered User Nova_Collision's Avatar
    Join Date
    Feb 2003
    Posts
    40
    I figured out that _popen only works for console apps. That's where the problem lies. :P
    When in doubt, empty your magazine - Murphy's Laws Of Combat #7

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, 09: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