tschak909 Posted January 5, 2021 Share Posted January 5, 2021 @Savetz did a #FujiNet chat program in Turbo BASIC XL using the N: handler. It is in /Networking/fujichat v01 dd.atr. 4 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted January 5, 2021 Author Share Posted January 5, 2021 The Chat Server: https://gist.github.com/tschak909/482725f078e08d456b7be670ddbddb07 import asyncio writers = [] def forward(writer, addr, message): for w in writers: if w != writer: w.write(f"{addr!r}: {message!r}\n".encode()) async def handle(reader, writer): writers.append(writer) addr = writer.get_extra_info('peername') message = f"{addr!r} is connected !!!!" print(message) forward(writer, addr, message) while True: data = await reader.read(100) message = data.decode().strip() forward(writer, addr, message) await writer.drain() if message == "exit": message = f"{addr!r} wants to close the connection." print(message) forward(writer, "Server", message) break writers.remove(writer) writer.close() async def main(): server = await asyncio.start_server( handle, '127.0.0.1', 8888) addr = server.sockets[0].getsockname() print(f'Serving on {addr}') async with server: await server.serve_forever() asyncio.run(main()) 1 Quote Link to comment Share on other sites More sharing options...
+David_P Posted January 5, 2021 Share Posted January 5, 2021 A few observations / questions: Other than a few DPEEK commands, and the MOVE command, I don't think it's using any Turbo BASIC commands; this could probably be translated to regular BASIC fairly easily. Line 9000 appears to have an error - it refers to line 8396, which does not exist in the listing. (On further examination, I'm wondering if line 9000 is used at all?) Line 8400 TRAPs line 40000, which doesn't exist. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted January 5, 2021 Author Share Posted January 5, 2021 1 minute ago, David_P said: A few observations / questions: Other than a few DPEEK commands, and the MOVE command, I don't think it's using any Turbo BASIC commands; this could probably be translated to regular BASIC fairly easily. Line 9000 appears to have an error - it refers to line 8396, which does not exist in the listing. (On further examination, I'm wondering if line 9000 is used at all?) Line 8400 TRAPs line 40000, which doesn't exist. Quite correct. Line 9000 is old code, isn't used. Line 40000 is the way to disable a TRAP. -Thom Quote Link to comment Share on other sites More sharing options...
+David_P Posted January 5, 2021 Share Posted January 5, 2021 ... so you're saying I have a project to port this to regular BASIC (and maybe finding an existing ML routine to move memory so things don't slow to a crawl when doing screen refreshes)... 1 Quote Link to comment Share on other sites More sharing options...
tschak909 Posted January 5, 2021 Author Share Posted January 5, 2021 yes. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.