I had a problem of not being able to pause the socket in a proxy type of application, when the client is sending from the local machine. I tried both Pause() and wsoNoReceiveLoop option. The socket will eventually pause, but it only happens after a few MByte data is received.
I might have found the problem of the socket not being paused. I'm trying both Pause() function and wsoNoReceiveLoop. Pause() makes sure I'm not interested in read event, and wsoNoReceiveLoop is suppose to make sure that we break out of the receive loop. However, the client (receiving) socket won't be able to pause until a few MBytes of data is received. This seems to be causing the problem: in the ASynReceive, the wsoNoReceiveLoop is checked against MySocketOptions, which is passed in the function and won't change until all data is received. If we use the member variable FComponentOptions, whose value can be set in the OnDataReceived handler. This way the loop can be effectively broken out of. The reason to use the function argument MySocketOptions instead of FComponentOptions is that in Do_FD_CLOSE() we want to look through the data (because there may not be another chance Receive() is called.) So my quick fix is: 1. use FComponentOptions in ASyncReceive() procedure TCustomWSocket.ASyncReceive( ... { DLR Honor the socket options being passed as parameters } //if wsoNoReceiveLoop in MySocketOptions then if wsoNoReceiveLoop in FComponentOptions then break; ... end; 2. In Do_FD_CLOSE(), remove wsoNoReceiveLoop flag in the member variable. procedure TCustomWSocket.Do_FD_CLOSE(var msg: TMessage); ... FComponentOptions := FComponentOptions - [wsoNoReceiveLoop]; ASyncReceive(0, FComponentOptions - [wsoNoReceiveLoop]); ... end; Please let me know if you see issues in this fix. -- Best regards, Jack -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be