07-11-2024, 05:55 PM
Code: (Select All)
DIM SHARED AS LONG x, y, client
SCREEN _NEWIMAGE(640, 480, 32)
host = _OPENHOST("TCP/IP:7319") ' no host found, so begin new host
IF host THEN
_SCREENMOVE 0, 0
DO
IF client = 0 THEN client = _OPENCONNECTION(host) ' receive any new connection
IF client THEN SendXY
x = x + 1: IF x > 1280 THEN x = 0
CLS
_PRINTSTRING (x, y), "Steve is Amazing"
IF x > 1280 - _PRINTWIDTH("Steve is Amazing") THEN _PRINTSTRING (x - 1280, y), "Steve is Amazing"
_DISPLAY
_LIMIT 30
LOOP
ELSE
_SCREENMOVE 640, 0
client = _OPENCLIENT("TCP/IP:7319:localhost") ' Attempt to connect to local host as a client
DO
GetXY
CLS
_PRINTSTRING (x - 640, y), "Steve is Amazing"
_DISPLAY
_LIMIT 30
LOOP
END IF
SUB SendXY
PUT #client, , x
PUT #client, , y
END SUB
SUB GetXY
GET #client, , x
GET #client, , y
END SUB
Inspired by Tempodi's topic: https://qb64phoenix.com/forum/showthread.php?tid=2855
Here, I wanted to create a true multi-screen program. Nothing fancy, but something nice and simple to showcase how easy it is to actually do something like this.
Try run this:
1) Run this.
2) Run a second version of this at the same time while the first version is running.
Then let both versions run for a complete cycle or two, to see the simple effect.
Note: You may need to jump through whatever bells and whistles your OS requires for network/TCP-IP communications and such with your FireWall and Security.