#1
  1. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510

    more telnet trouble


    This is for the same app that I had a question on a couple weeks ago about function keys, where I'm automatically updating wireless access points. I have that issue solved but I've run up against something else. I'm trying to send a short string (15 characters max) to the access point. Everything else I send is a one character command. For some reason I'm only getting the first character across (I know because it echos what you send). I have tried sending the entire string, but I know telnet really expects individual packets with one character in each packet for input, and so I've also tried looping through and sending each character. Still only get the first character to go. Here's the kicker: if I step through the app in the debugger (borland builder), it works like a charm. I'm not quite sure what the difference is except that maybe there is a speed issue involved (sending them out in the program they're too close together and get mixed up or lost somehow, but tcp is supposed to be more reliable than that). I could just use a timer, but this is already part of another timer call. Any other ideas about how I can make it pause for a moment between sending each packet?
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  2. #2
  3. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    perhaps im stating the obvious here, but how bout a call to sleep() or usleep() ?
  4. #3
  5. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510
    no good. Not using threads, just a timer. I worked around it by using a couple nested while loops to eat up a few thousand clock cylces between each character, but that's very poor technique and I know it. Any ideas on how to to it better?
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,091
    Rep Power
    2222
    Originally posted by f'lar
    no good. Not using threads, just a timer. I worked around it by using a couple nested while loops to eat up a few thousand clock cylces between each character, but that's very poor technique and I know it. Any ideas on how to to it better?
    Huh? Non sequitur. sleep() (and Sleep() for Win32) is available whether you're using threads or not. Just be sure about whether the argument is in seconds (as in Linux) or milliseconds (Win32, even the MinGW port of gcc calls for milliseconds).

    BTW to Infamous: thanks for word on usleep for Linux, which takes microseconds. Hadn't heard of it before.

    f'lar, if you're working in Windows then you could also look at doing a SetTimer() and then handle the WM_TIMER event.

    In Linux, you could call alarm() and then handle the SIGALRM signal.

    And at no point would you ever need to use threads.
  8. #5
  9. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510
    Okay. sleep() wasn't available to me, but Sleep() works great. I made the threads comment because i did some searching and a few results came up relavent to using threads. Should've thought to check case. thanks
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn

IMN logo majestic logo threadwatch logo seochat tools logo