TcpServer class with libuv thread, socket pkg and a Qt GUI

112 views
Skip to first unread message

Oscar

unread,
Dec 17, 2020, 2:00:38 PM12/17/20
to The Ring Programming Language

Hello everyone,
  I implemented a TcpServer  module (re-inventing the wheel for fun) that uses the socket package and the thread API from libuv. I tried to have it update a textbox whenever a client connects but instead got this error:

"Line 1 Error (R24) : Using uninitialized variable : tcpserver
in file Ring_EmbeddedCode QObject::~QObject: Timers cannot be stopped from another thread"

Can you please help me troubleshoot the problem by unpacking the attached archive and running Main.ring in debug mode? If you get past the above error, please also run time_client.ring in order to send requests to the server.

Thank you!
Oscar.
sockets.zip

Ilir

unread,
Dec 17, 2020, 7:04:03 PM12/17/20
to The Ring Programming Language
Hello Oscar,

here is how you can do it (see attachment). Please note: I had to use "new Local { close(client_sock) }" trick to escape TcpServer scope, otherwise objectslib's close function is called. Wonder if there is a better way to do it.

sockets.zip

Oscar

unread,
Dec 17, 2020, 9:21:01 PM12/17/20
to The Ring Programming Language
Thanks a lot Ilir!
Your contributions helped med understand how to better navigate the global and object scopes in Ring.
Great fix!

Oscar.

Bert Mariani

unread,
Dec 18, 2020, 11:05:11 AM12/18/20
to The Ring Programming Language
Hello Oscar, Ilir

Get this message after starting Time_Client
See capture for sequence of steps

Enter a char to exit: w
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)
"

OscarClientServer.png

Mahmoud Fayed

unread,
Dec 20, 2020, 8:50:39 AM12/20/20
to The Ring Programming Language
Hello Oscar, Ilir

Thanks for sharing :D


Keep up the GREAT WORK :D

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages