• Welcome to Valhalla Legends Archive.
 

Staying Connected

Started by gorshing, June 27, 2003, 05:36 PM

Previous topic - Next topic

gorshing

I am going to develop a bot using C++ (MS 6.0) I have some source code from a VB bot that I am going to go off of.

But the main problem with the VB bot is that it loses it's connection frequently.  I would like to be able to stay connected ... is there something that I could send battle.net to let it know that I am still alive?

I will use WSAAsyncSelect (I believe that is correct) for FD_READ, FD_ACCEPT, and FD_CLOSE ... so when I get disconnected I will connect again ... but I would like to try and prevent, as much as possible, getting disconnected.

Any ideas, or older posts that I have missed?

Thanks for any help,

Camel

Send an 0x0 packet (no data, just FF 00 04 00) every once in a while. At the very least, send one back whenever battle.net sends you one.

iago

every 60 seconds is ideal.

One way to do this in c++ is to have a timer thread, but that's a little nasty (you have to do some thread synchronization).  Or in your main loop you can check if the current time in seconds is divisible by 60 and if it is send out that packet.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Camel

Couldn't one just use select() and have it give up after 60 seconds?

Brolly

Or you can use SetTimer() and handle WM_TIMER.

Camel

Quote from: Brolly on June 29, 2003, 09:07 PM
Or you can use SetTimer() and handle WM_TIMER.

Would that be more simple?

Brolly

Yes. Every X seconds, a WM_TIMER message will be sent. You might not be able to do this in VB, however.

DarkMinion

You can use timers in VB, it's just different.

Camel

Quote from: DarkMinion on June 30, 2003, 12:50 PMYou can use timers in VB, it's just different.
Well, basicly it's just a CallBack function (which is a paint to debug as the entire VB process will be terminated if the callback function fails to return). VB timer objects are rather useful when efficiency is not the goal.

DarkMinion

Yes, I went through that particular hang once when I used VB.

gorshing

Thanks for all the replies ... that's what I figured for a binary bot.

My apologies for not specifing that I am working with a chat bot.

Sorry once again,