BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"OpenTCPStream lag demo"
, by thechange
When a client connects to a host, the program will be paused for a certain amount of time.
Code
; Demonstration of the hazardous pause the OpenTCPStream command introduces. ; Related thread: ; ; http://www.blitzcoder.com/cgi-bin/ubb-cgi/postdisplay.cgi?forum=Forum11&topic=000080 ; ; Press
to enable/disable connection attempts Const ScreenSizeX = 1000 ; Wide screen Const ScreenSizeY = 400 Graphics ScreenSizeX , ScreenSizeY , 0 , 2 ; Wide screen (windowed) SetBuffer BackBuffer() ;<-- Const RemoteIP$ = "127.0.0.1" ; Remote (host) IP address Const RemoteTCP = 2012 ; Remote (host) TCP port Const Interval = 2000 ; Connection attempt interval (ms) CountHostIPs "" LocalIP$ = DottedIP ( HostIP ( 1 ) ) Repeat If MilliSecs () > LastTime + Interval LastTime = MilliSecs () ; Sync to MS() ; By placing the LastTime synchronizing to MilliSecs () code ; here, you will be able to see how much time is consumed by ; the connection attempt. If Toggle ConnectTCP = OpenTCPStream ( RemoteIP , RemoteTCP ) End If ; LastTime = MilliSecs () ; Sync to MS() ; By enabling the LastTime synchronizing to MilliSecs () code ; here, the program will wait a full interval time after each ; connection attempt. End If Text 10 , 10 , "Slave: " + LocalIP Text 10 , 20 , "Master: " + RemoteIP RemainingTime = MilliSecs () - LastTime Text 10 , 30 , "Remain: " + RemainingTime Text 10 , 40 , "Toggle: " + Toggle RelativeAngle = RemainingTime * 360 / Interval PosX = ScreenSizeX/2 + Cos ( RelativeAngle ) * (ScreenSizeX/3) PosY = ScreenSizeY/2 + Sin ( RelativeAngle ) * (ScreenSizeY/3) Oval PosX , PosY , 10 , 10 Flip Cls If KeyHit ( 57 ) Toggle = Not Toggle End If Until ConnectTCP Or KeyHit ( 1 ) End ;-->
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations