Hello wayne, if your socket is attached to a thread and multithread is true then all events will fire in the same thread context. after OnSessionClosed is fired (with or without error) you should not send data after it.
I think it is also a good idea to put all send operations in an exception block just in case something happens. --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Wednesday, February 6, 2008, 11:10, wayne forrest wrote: > Thank you Wilfried, > I think I have found the Problem, but still not sure what to "Check" for, > I did a Stack Trace: > First event is 10053 : Socket Disconnected, then because I was sending Data, > this code then continues to be executed: > size := Swap4(DataStream.Size); > aThread.Send(@size, len); > aThread.Send(@b[0],DataStream.Size); > if aThread.ClientThread.ThreadAttached then // > has no Effect to catch Access Violation > aThread.TryToSend; > Is there a Way that I can Detect the LastError Code for the Current Thread: > as in > if aThread.ErrorFree then begin > // do my send operations. > end; > Thank you. > On Feb 6, 2008 11:09 AM, Wilfried Mestdagh <[EMAIL PROTECTED]> wrote: >> Hello wayne, >> >> Yes you probably access an object that never has created, or there is >> some pointer overwritten. When you have the exception view the call >> stack window to go to the offending code. >> >> --- >> Rgds, Wilfried [TeamICS] >> http://www.overbyte.be/eng/overbyte/teamics.html >> http://www.mestdagh.biz >> >> Wednesday, February 6, 2008, 09:32, wayne forrest wrote: >> >> > I have an Access Violation at address 00000, I googled on this and found >> > that this means a reference to a null. >> >> > Basically I have implemented my Application based on "ThrdSrvV2_1" demo >> > project, >> >> > The problem happens as Follows: The Client connects to the Server, then >> > requests data, >> > I then Close the Client Application (Terminate / end task). >> >> > the server then runs into this Routine: I am not sure where the Error is >> > precisely, I think it is when the Windows Message gets processed. >> > inside the "Forms unit" of delphi. >> >> > Any Ideas. >> >> > {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * >> > *} >> > { We have to attach client socket to this thread's context and then >> > } >> > { process messages so that TWSocket events works. >> > } >> > procedure TClientThread.Execute; >> > begin >> > if not Assigned(WSocket) then >> > Exit; >> >> > { Attach client socket to this thread >> > } >> > WSocket.ThreadAttach; >> > { Signal main thread that we've attached socket to this thread >> > } >> > ThreadAttached := TRUE; >> > { Now let main thread continue starting the connection. >> > } >> > { This little avoid race condition. >> > } >> > Sleep(0); >> > { Let's block on critical section already owned by main thread >> > } >> > EnterCriticalSection(FCritSect); >> > LeaveCriticalSection(FCritSect); >> > { Then process messages until WM_QUIT message is posted. >> > } >> > { TWSocket is event-driven. So even when used within a thread, we >> > } >> > { have to have a "message pump". Any message pump will do and there >> > } >> > { is one built in TWSocket, so use it ! >> > } >> > WSocket.MessageLoop; >> > { Be sure to have main thread waiting for termination before >> > terminating} >> > Sleep(0); >> > { Detach the hidden window from within the thread >> > } >> > WSocket.ThreadDetach; >> > end; >> >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be >> > -- > C: 076 337 4368 > T: 021 880 2037 > F: 021 880 2530 -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be