Click here to Skip to main content
15,442,199 members

Comments by Bram van Kampen (Top 18 by date)

Bram van Kampen 11-May-12 19:28pm View     CRLF
Well I have One thread per Connection, but use WSAAccept to limit it to a reasonable number. I also have (on a Seperate thread) a Garbage Collection Service, that kills stale sockets. Any Sockets, not Kicked within a period, get Closed, the thread running it also gets closed. The Socket (or Thread) gets kicked when traffic passes tru it, and a new period starts. Each WSAAccept(...) is not sent off into the dark on a New thread, and a New Socket. The situation is carefully monitored, and the Callback in WSAAccept() will return 'CF_REJECT' if Too Many Sockets are open already.
Bram van Kampen 15-Apr-12 20:44pm View     CRLF
Thanks, With PARANOID turned on I thought I created a Pointer on the Local Stack, pointing to a Global Object This pointer is passed to the thread's stack, but still points to the same global object. I take it that all that is done when 'CreateThread' returns. MS Documentation states specfically that 'CreateThread' may return before the Newly Started thread completes( Otherwise 'CreateThread' would be pointless)or even before it commences! I had Bad feelings about the code without 'PARANOIDE', and you confirm my bad feelings about it. The problem with synchronisation objects is, that I would have to apply the Lock in the Parent thread, and release it from the Child Thread. This is Something that does not sound right. (Having said that, maybe it is perfectly acceptable). Apart from that, what I'm trying to do is not exactly breaking the mould. Useage of the 'CreateThread' function is peppered through all MS Apps. I can only assume that they made it 'Usefull'. Unless if anyone comes up with a different Idea, I will for now assume that You're right in considering the 'PARANOIDE' option as threadsafe. Thanks; Regards :)
Bram van Kampen 12-Apr-12 20:41pm View     CRLF
QQQ How can a Single threaded app endup creating an unlimited number of sockets! I do not understand this at all! Surely a single threaded function can count the number of created sockets in a single global variable. (Does not need protection, because there is only one thread.) The CallBack of WSAAccept can reject the new socket, if too many are open. At any rate, this is a latter day issue. For now I just want to establish basic connectivity. Regards, Bram.
Bram van Kampen 12-Apr-12 15:37pm View     CRLF
Well, One thing at a time. I'm at experimental stage 0, and the first concern is what type of incantations are required to ensure that after the 'send(h_sockClient...)' , and going round the loop, 'listen(hSock,100)' works properly again. I'm debuging this with one client, and efficiency does not (yet) come in to it. I would have thought that for this testing purpose, one thread should suffice. :) Bram.
Bram van Kampen 9-Apr-12 19:48pm View    
enhzflep below got it right!