Author Topic: Test this and chat with me  (Read 5165 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Test this and chat with me
« on: November 10, 2020, 01:50:47 pm »
Code: Text: [Select]
  1. DIM SHARED OUT$, myname$
  2. DIM l AS _UNSIGNED _BYTE
  3.  
  4. PRINT "[Steve's Mini Messenger]"
  5. client = _OPENCLIENT("TCP/IP:7993:172.93.60.23") ' Attempt to connect to Steve's PC host as a client
  6. PRINT "[connected to " + _CONNECTIONADDRESS(client) + "]"
  7.  
  8. INPUT "Enter your name: ", myname$
  9. OUT$ = myname$ + " connected!"
  10. l = LEN(OUT$)
  11. PUT #client, , l
  12. PUT #client, , OUT$
  13. 'PRINT "OUT$: "; OUT$
  14. DO
  15.     GetMessage client
  16.     SendMessage mymessage$, client ' display current input on screen
  17.     _LIMIT 30
  18. LOOP
  19.  
  20. '.................... END OF MAIN PROGRAM ................
  21.  
  22.  
  23. SUB GetMessage (client) ' get & display any new message
  24.     DIM l AS _UNSIGNED _BYTE
  25.     GET #client, , l
  26.     IF l > 0 THEN
  27.         _DELAY .1 'some delay so the other 'puter can send the info to us across spiderman's excretions!
  28.         OUT$ = SPACE$(l)
  29.         GET #client, , OUT$
  30.         VIEW PRINT 1 TO 20
  31.         LOCATE 20, 1
  32.         PRINT OUT$
  33.         VIEW PRINT 1 TO 24
  34.     ELSE
  35.         OUT$ = ""
  36.     END IF
  37. END SUB
  38.  
  39. SUB SendMessage (mymessage$, client) ' simple input handler
  40.     DIM l AS _UNSIGNED _BYTE
  41.     k$ = INKEY$
  42.     IF LEN(k$) THEN
  43.         IF k$ = CHR$(8) AND LEN(mymessage$) <> 0 THEN
  44.             mymessage$ = LEFT$(mymessage$, LEN(mymessage$) - 1)
  45.         ELSE
  46.             IF LEN(k$) = 1 AND ASC(k$) >= 32 THEN mymessage$ = mymessage$ + k$
  47.         END IF
  48.     END IF
  49.     VIEW PRINT 1 TO 24
  50.     LOCATE 22, 1: PRINT SPACE$(80); ' erase previous message displayed
  51.     LOCATE 23, 1: PRINT SPACE$(80); ' erase previous message displayed
  52.     t$ = myname$ + ": " + mymessage$
  53.     LOCATE 22, 1: PRINT t$;
  54.     IF k$ = CHR$(13) OR LEN(t$) = 255 THEN ' [Enter] sends the message
  55.         IF mymessage$ = "" THEN SYSTEM ' [Enter] with no message ends program
  56.         mymessage$ = myname$ + ":" + mymessage$
  57.         l = LEN(mymessage$)
  58.         PUT #client, , l
  59.         PUT #client, , mymessage$
  60.         _TITLE mymessage$
  61.  
  62.         mymessage$ = ""
  63.     END IF
  64.     IF k$ = CHR$(27) THEN SYSTEM ' [Esc] key ends program
  65. END SUB
  66.  

I've finally taken time to set up all the port forwarding and firewall exceptions for my new PC to start working as a webserver once again.  (I think.)  If anyone likes, feel free to try the code above and let me know if you can connect and say "Hi" to whomever might be sitting around and goofing off in the little mini-messenger chat room I'm testing.

Note:  This little room is subject to self-destruct at any time, so if you can't connect, just post a message here and don't worry about it.  Chances are, someone else verified that things are working properly for me, and I've just shut down the experiment afterwards so I can go back about getting my personal web pages back up and such.  :)
« Last Edit: November 10, 2020, 05:48:24 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Test this and chat with me
« Reply #1 on: November 10, 2020, 02:16:15 pm »
Hi Steve. Program generate error message "Out of memory" for me.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Test this and chat with me
« Reply #2 on: November 10, 2020, 02:18:39 pm »
Row 28 do it?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Test this and chat with me
« Reply #3 on: November 10, 2020, 02:21:21 pm »
Out of memory??

How the heck did I accomplish that!

  [ You are not allowed to view this attachment ]  

Something somewhere isn't working as intended.  Almost 2GB memory for the client???  I'm digging into the issue.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Test this and chat with me
« Reply #4 on: November 10, 2020, 02:32:38 pm »
That worked pretty well, Steve. Good luck on finding the memory leak! I'm willing to do more tests for you in the future if need-be.
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Test this and chat with me
« Reply #5 on: November 10, 2020, 02:34:24 pm »
Close the server, restart it, and now my memory usage is running down at around 50-80MB.  Guess I'll let it go for a while and see if the amount creeps up over time.  If so, there's a memory leak in there somewhere, but I don't have a clue where it might actually be at.

At least I got a good test result from it, and it shows that my ports are forwarded properly now, and my firewall exceptions are all working as intended.  Spriggys connected to my system and sent and received information properly, and that was the most important thing that I was wanting to confirm.  Program glitches can be ironed out anytime now; I just needed to see if I could open that remote connection and send/receive data properly, and I'm happy to report that that is a success, at least. :)
« Last Edit: November 10, 2020, 02:38:25 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Test this and chat with me
« Reply #6 on: November 10, 2020, 03:03:36 pm »
My output:

  [ You are not allowed to view this attachment ]  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Test this and chat with me
« Reply #7 on: November 10, 2020, 03:16:22 pm »
Looking at it, I imagine the glitch is in lag over the net.

I bet when I send the length of &H0000000F (in hex, for 15 bytes), you’re receiving it in chunks like:  &H000000 (which is 3 bytes of zero, which is 0), followed by &H0F123456 (which would be that 15 in length + the first 3 bytes of user data transfered).

This is generating you a string of super size, and giving you the mem usage you’re seeing.

Fix would be to send a text limit of 255 characters, and read a single _UNSIGNED _BYTE for the length.  (Or prefix with a single byte as an indicator to prepare for proper data of X size, following.)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Test this and chat with me
« Reply #8 on: November 10, 2020, 03:22:06 pm »
I run it again under 64bit IDE QB64 v. 1.4 and works fine! Under 32bit QB64 v. 1.5 it do memory leak. I am connected now under QB64 1.4.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Test this and chat with me
« Reply #9 on: November 10, 2020, 03:49:54 pm »
Chat test server is currently down for investigative purposes.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Test this and chat with me
« Reply #10 on: November 10, 2020, 04:12:28 pm »

Hi ! I tried it ! unfortunately it can be seen in the attached picture, he stopped there, did not go any further. i put it in my own folder and started from there, before that avaston turned off protection. I have win7. i hope this helped something. let me know if you can join! I find it exciting to have a private network communicating on the net.

  [ You are not allowed to view this attachment ]  

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: Test this and chat with me
« Reply #11 on: November 10, 2020, 04:59:07 pm »
Hello

I get a black screen that says "[Steve's Mini Messenger]" then my comput will just lock up for a couple of minutes then i get bad file mode in line six.

Badger

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Test this and chat with me
« Reply #12 on: November 10, 2020, 05:10:57 pm »
Guys...

Quote

Chat test server is currently down for investigative purposes.


You can’t connect to a server that isn’t running...
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Test this and chat with me
« Reply #13 on: November 10, 2020, 05:17:33 pm »
Hi Steve
I try now your Mini Messenger ...
I got the same position of Badger, and if I click on Yes of Continue? msgbox I got other errors on line 11 12 13 and then 25.... all the same error Bad File Name or Number..
here a screenshot
  [ You are not allowed to view this attachment ]  

Quote
You cannot connect to a server that is not running... 
LOL you're right! :-))))
« Last Edit: November 10, 2020, 05:19:51 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Test this and chat with me
« Reply #14 on: November 10, 2020, 05:46:52 pm »
Since several folks were wanting to have fun and test this, the code in the original post has been fixed and the server is now back up and running again.  Hopefully, the excessive memory issue has been corrected, and things work as they should.  Feel free to pop in and give us a chat anytime you guys want, for the next few hours.

Code: QB64: [Select]
  1. DIM SHARED OUT$, myname$
  2.  
  3. PRINT "[Steve's Mini Messenger]"
  4. client = _OPENCLIENT("TCP/IP:7993:172.93.60.23") ' Attempt to connect to Steve's PC host as a client
  5. PRINT "[connected to " + _CONNECTIONADDRESS(client) + "]"
  6.  
  7. INPUT "Enter your name: ", myname$
  8. OUT$ = myname$ + " connected!"
  9. l = LEN(OUT$)
  10. PUT #client, , l
  11. PUT #client, , OUT$
  12. 'PRINT "OUT$: "; OUT$
  13.     GetMessage client
  14.     SendMessage mymessage$, client ' display current input on screen
  15.     _LIMIT 30
  16.  
  17. '.................... END OF MAIN PROGRAM ................
  18.  
  19.  
  20. SUB GetMessage (client) ' get & display any new message
  21.     GET #client, , l
  22.     IF l > 0 THEN
  23.         _DELAY .1 'some delay so the other 'puter can send the info to us across spiderman's excretions!
  24.         OUT$ = SPACE$(l)
  25.         GET #client, , OUT$
  26.         VIEW PRINT 1 TO 20
  27.         LOCATE 20, 1
  28.         PRINT OUT$
  29.         VIEW PRINT 1 TO 24
  30.     ELSE
  31.         OUT$ = ""
  32.     END IF
  33.  
  34. SUB SendMessage (mymessage$, client) ' simple input handler
  35.     k$ = INKEY$
  36.     IF LEN(k$) THEN
  37.         IF k$ = CHR$(8) AND LEN(mymessage$) <> 0 THEN
  38.             mymessage$ = LEFT$(mymessage$, LEN(mymessage$) - 1)
  39.         ELSE
  40.             IF LEN(k$) = 1 AND ASC(k$) >= 32 THEN mymessage$ = mymessage$ + k$
  41.         END IF
  42.     END IF
  43.     VIEW PRINT 1 TO 24
  44.     LOCATE 22, 1: PRINT SPACE$(80); ' erase previous message displayed
  45.     LOCATE 23, 1: PRINT SPACE$(80); ' erase previous message displayed
  46.     t$ = myname$ + ": " + mymessage$
  47.     LOCATE 22, 1: PRINT t$;
  48.     IF k$ = CHR$(13) OR LEN(t$) = 255 THEN ' [Enter] sends the message
  49.         IF mymessage$ = "" THEN SYSTEM ' [Enter] with no message ends program
  50.         mymessage$ = myname$ + ":" + mymessage$
  51.         l = LEN(mymessage$)
  52.         PUT #client, , l
  53.         PUT #client, , mymessage$
  54.         _TITLE mymessage$
  55.  
  56.         mymessage$ = ""
  57.     END IF
  58.     IF k$ = CHR$(27) THEN SYSTEM ' [Esc] key ends program

(Code reposted here, for convenience's sake, as well as edited and corrected in the original post above.)
« Last Edit: November 10, 2020, 05:48:09 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!