Home » U++ Library support » U++ MT-multithreading and servers » Need a working simple example of using sockets with GUI in U++
Need a working simple example of using sockets with GUI in U++ [message #40409] |
Wed, 31 July 2013 03:24  |
lectus
Messages: 329 Registered: September 2006 Location: Brazil
|
Senior Member |
|
|
I tried everything, but it isn't straight forward for me.
This really needs a simple example. I understand sockets in console, but in GUI it seems you need to use threads.
How can you build a simple TCP/IP GUI chat that can act as client or server and send/receive messages?
Thanks
|
|
|
|
Re: Need a working simple example of using sockets with GUI in U++ [message #40469 is a reply to message #40460] |
Mon, 05 August 2013 23:06   |
Oblivion
Messages: 1206 Registered: August 2007
|
Senior Contributor |
|
|
koldo wrote on Mon, 05 August 2013 10:40 | Hello Lectus
Few weeks ago I began to prepare some functions to communicate different programs in different computers using sockets (in plain words, I am a dummy in sockets ).
Based in U++ Reference/SocketClient and SocketServer it was very simple. It is also very easy to use threads in U++ (just following a couple of simple rules: 1. debug your code before being multithreaded, 2. do not share variables but if you do it, use for example INTERLOCKED), so including in the same program the client and a multi threaded server has been straightforward.
Where are the problems you find?
|
Hello Koldo, I agree Lectus.
IMO, it is generally a better practice to use sockets with threads in a GUI application, but U++ needs a basic single-threaded non-blocking client/server socket example too. While I can use a traditional low level platform dependent socket routines to handle nonblocking socket operations, I have to admit that I find U++ TcpSocket class a bit confusing. A code snippet or a barebone example on, say, how to handle basic nonblocking read()/Get() and write()/put() operations with TcpScoket, and how to cancel or do "other stuff" when socket would block (e.g, canceling the operation) would be really useful.
Regards.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Mon, 05 August 2013 23:10] Report message to a moderator
|
|
|
Re: Need a working simple example of using sockets with GUI in U++ [message #40526 is a reply to message #40469] |
Fri, 09 August 2013 08:34  |
 |
koldo
Messages: 3435 Registered: August 2008
|
Senior Veteran |
|
|
Hello Oblivion and Lectus
I cannot answer to that properly because I am not an expert in sockets.
Anyway I have prepared some classes that work for me very well including a multithreaded server, with few code, just three sheets of paper when printed. I have done some homemade stress tests and it has worked as expected.
If you are interested I can send you a copy of this in the end of August because now I am on holidays and I would like to prepare a simple GUI for it.
Best regards
Iñaki
|
|
|
Goto Forum:
Current Time: Fri May 09 15:54:21 CEST 2025
Total time taken to generate the page: 0.02673 seconds
|