socket in threads,or threads in socket?

socket as proterty of thread class ,or threads as property of socket class,
which style would you choice?

Thread as a property of a Socket.

I also likes this

Just out of curiosity: Why? :slight_smile:

Will sockets misbehave if called from a thread?

If I am not mistaken, sockets events happen in the main thread anyway. So placing them in a thread is no advantage over using sockets in asynchronous mode.

The problem is often that events from sockets are not always on the main thread.
There are cases where you get them on threads. At least for older Xojo versions.

Anyway, if the intent is to prevent UI freeze, an asynchronous socket is way less overhead.

There is a known problem with xojo.Core.httpsocket where it’s page received event doesn’t fire when the object is in a thread.