Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
lectus is currently offline  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 #40460 is a reply to message #40409] Mon, 05 August 2013 09:40 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
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 Rolling Eyes ).

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?


Best regards
Iñaki
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 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
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 Rolling Eyes ).

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.


[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 Go to previous message
koldo is currently offline  koldo
Messages: 3355
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
Previous Topic: url-encoded binary data in URL query string - how to decode properly?
Next Topic: Lost socket error (and how to get it)
Goto Forum:
  


Current Time: Fri Mar 29 15:44:39 CET 2024

Total time taken to generate the page: 0.01529 seconds