Asm code not working anymore on PB v4 :(

Just starting out? Need help? Post your questions and find answers here.
Fred
Administrator
Administrator
Posts: 18161
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Please calm down. You can't be angry when you hack that much in the PB commandset. When we change something in the PB internals, we can't be backward compatiable with such hack. Just keep the v3.94 for your project and you're done.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

If you want a timeout function (its probably not very safe but what the heck :) )

Code: Select all

Procedure scan(i)

 a=OpenNetworkConnection(target.s,i)
 Debug a
 If a
  Print( " open!")
  CloseNetworkConnection(a)
 Else
  Print( " closed!")
 EndIf

EndProcedure

timeout=2000

th=CreateThread(@scan(),i)

If th
WaitThread(th, timeout)   ;If the thread is created, wait the specified time till it stops. If not; continiue!
EndIf


If IsThread(th) ;Is thread active?
KillThread(th)  ;if so, kill it.
Print( " Timeout! (possibly closed)") 
EndIf
Its just a part of a port scanner..
Its a bit messed up :P
Phlos
User
User
Posts: 85
Joined: Fri May 16, 2003 7:17 pm

Post by Phlos »

Fred wrote:Please calm down. You can't be angry when you hack that much in the PB commandset. When we change something in the PB internals, we can't be backward compatiable with such hack. Just keep the v3.94 for your project and you're done.
I cannot, Thread safe, Mutex, ... so much nice features in PB v4 that I already use. :(
I just hope you will add a TimeOut when you have some free time :wink:
Phlos
User
User
Posts: 85
Joined: Fri May 16, 2003 7:17 pm

Post by Phlos »

Thank you for your code thefool, but it's not really good to kill Threads :?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Phlos; generally its not. However i havent found any problems in this situation.

but its true; the thread has no chance to free memory, or deallocating stuff. But then again; Why wouldn't the old memory just be overwritten. for this purpose it works great; but if you need to do more than this it might not be a good idea.

Actually; perhaps this is the way timouts normally work in these situations :P

Anyway its the only solution i got at the moment..
Post Reply