TCP over COM ports

Web Tools, Utilities, and Applications written in Just BASIC
NTech
Posts: 31
Joined: Mon May 01, 2017 7:29 pm
Location: USA

TCP over COM ports

Post by NTech » Thu May 02, 2019 7:55 pm

Download here: https://nofile.io/f/d7D4JnBTPJR/TCP-Ser ... r-v100.zip (20mb)

Features

-Multiple clients, ONE JB thread.
-Client I/O differentation: send text to one, or all clients.

What It Does

I've bundled together com0com, and a python script. What they do is create two
COM ports (COM10 and 11) and link them. The python script listens on port 3000
and any information received is sent to com11 (which com0com relays to com10).

Included is a step-by-step instruction guide (which takes 2 minutes to work through,
at the end of that 2 minutes, you'll be running and playing 567MUD in JustBasic!)

Once it is all set up, you'll be able to use JustBasic to make a MUD (like the one
included), a HTTP/HTTPS server, a SMTP server, anything that can be done over
TCP. If you have troubles connecting, make sure to allow connections to port 3000
in Windows Firewall.

Download https://nofile.io/f/d7D4JnBTPJR/TCP-Ser ... r-v100.zip, unzip it, and follow the instructions in README.txt, roughly from top to bottom.

Create anything?

If you've improved 567MUD, please share it below (just the .bas, there's no need to include the installers, scripts and such.

Bug reports, and improvements

If you have a bug, report it here. If you want a new feature to the relay, put it here too.
8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)

NTech
Posts: 31
Joined: Mon May 01, 2017 7:29 pm
Location: USA

Re: TCP over COM ports

Post by NTech » Thu May 02, 2019 8:04 pm

New (and permanent) link to that ZIP file:
https://github.com/servusDei2018/COM-TCP-JustBasic
8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)

NTech
Posts: 31
Joined: Mon May 01, 2017 7:29 pm
Location: USA

Re: TCP over COM ports

Post by NTech » Fri May 03, 2019 4:26 pm

Version 1.01

Due to problems people were having downloading the previous files, I've transferred everything to Github.

:!: You'll find the files this guide specifies here.

New Instructions


Note: For this guide, I shall assume you are putting everything in Documents\Com-Tcp

Installing COM0COM

Com0Com is a necessary component of this framework. This part of the guide shall guide you through
installing it, and using it to create two virtual COM ports - COM10 and COM11 which it shall link together.

1. Download "com0com installers.zip" from Github and place it in Documents\Com-Tcp
2. Unzip it.
3. Inside, you'll find two installers, one for x86 (32 bit) and one for x64 (64 bit). Install it, and click finish.
4. Now, from the Start Menu, type in "Setup for com0com" and click on that application.
5. A command-prompt style window shall appear. Enter in "install Portname=COM10 Portname=COM11".
6. Enter in "quit".

Downloading and Running the Python Relay

The Python Relay is a necessary component of this framework. This part of the guide shall guide you through downloading it, unzipping it, and running it. This relay opens a listener on port 3000 of localhost (your IP address) and forwards all information to COM11, which through Com0Com is linked to COM10 (on which JustBasic can listen -- more on that below).

1. Download "tcp-serial-server and support files.zip" from Github and place it in Documents\Com-Tcp
2. Unzip it.
3. Inside, you'll find one folder, two batch files, and one text-document README.
4. Test to see if Com0Com was configured successfully: double-click "runRelay.bat"
Running this shall start up the listener and begin forwarding everything to COM10 (it doesn't matter
if JustBasic is listening yet). Running it should produce this output:

Code: Select all

	tcp-serial-server.py:79: SyntaxWarning: name 'players' is used
	prior to global declaration
	  global players
	Initializing server/socket...
	Server/socket initialized!
	Initializing serial...
	Serial initialized!
5. To shut it down, just close the window. But leave it running if you're going to use the sample program.

Using JustBasic to interface with the Relay

The sample JustBasic program is a very simple MUD -- 567MUD, which stands for (5-rooms, 6-items, 7-commands)MUD. It shows the basics of interacting with the relay.

1. Download "sampleBASProgram.zip" from Github and place it in Documents\567MUD.
2. Make sure the relay is running (if not, run "runRelay.bat")
3. Now, run "communicator.bas"
4. 567MUD is now operational.
5. You can connect to localhost port 3000 with any MUD or telnet client, or, you could use the included
telnet client (it doesn't support color) by running "telnet.bat".

END OF GUIDE

Interacting with the Relay

Here is a synopsis of how to, with JustBasic, interact with the relay.

When a new client connects to port 3000, the relay sends over COM10 "NP playerID|" where playerID is
an integer. If a client disconnects, the relay sends "DC playerID|". Whenever the client sends text over port 3000, the relay sends "playerID whatHeSent|". Note that there are "|" included; the relay includes these thatway processing the COM10 input is made easier by the recognition that each line is delimited by a "|" symbol.

The JustBasic server can reply, over COM10, "playerID textToSend moreTextToSend", to send any amount of text to a client defined by playerID. It may also broadcast data to all clients as a whole by "all textToSend". Finally, to disconnect all clients, it may send "zapzap".

Note that JustBasic can manage infinite clients, all over COM10. Do NOT open COM11 as this shall mess up the relay. The suggested code to open up the COM10 port is:

Code: Select all


open "Com10:9600,n,8,1" for random as #handle

All the settings are hard-wired, a change in one might (I haven't tried) mess all of it up, because the relay is set to a baudrate of 9600, no parity, 1 stopbit, and 8bits bytesize.
8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)