You are putting the socket into its own thread and then trying to use the socket in non-blocking mode. That explains why you can't get it to work correctly. Non-blocking sockets use window message internally, which means that the owning thread requires an active message queue. Your thread has no message queue of its own at all, thus the socket can't operation correctly.
You need to either:
1) give the thread a message queue so that the socket can process its
internal notifications
2) set the socket's ClientType property to ctBlocking instead. That will
put the socket into blocking mode, in which case window messages are no
longer used and a message queue is not needed. You will need to use a
TWinSocketStream to access the socket for reading and writing, though.
1) give the thread a message queue so that the socket can process its
internal notifications
2) set the socket's ClientType property to ctBlocking instead. That will
put the socket into blocking mode, in which case window messages are no
longer used and a message queue is not needed. You will need to use a
TWinSocketStream to access the socket for reading and writing, though.
Partager