Hello
I have a server side program, it receive client message with WinSock. After receiving data, it will process the content and return a result message to client. If process result is successful (0), server side will open a form to keep process the next step, and close itselft at the same time. The problem is: When I open the form, sendData will not process until the new form was closed. I tried to run unload current form only, it will turn to unload but still cannot send response. It seems that SendData in DataArrival will process until DataArrival Complete. How to fix this problem? Thanks a lot and sorry for my poor English. Here is the related code:
Code:Private Sub sckPDA_DataArrival(Index As Integer, ByVal bytesTotal As Long) Dim sStatus As String 'Process received data sckPDA(Index).GetData sStatus, vbString If VerifyStatus(sStatus) Then resmsg = "0" blnStatusCorrect = True Else resmsg = "-1" blnStatusCorrect = False End If 'A feedback to client side If sendResponse(resmsg) = True Then sckSend.Close 'Open form to process next step frmPhase2.Show vbModal, Me End If Unload Me End Sub Private Function sendResponse(ByVal resmsg As String) As Boolean sckSend.Close sckSend.Connect sendResponse = False Do DoEvents If sckSend.State = sckConnected Then sckSend.SendData resmsg sendResponse = True End If Loop Until sckSend.State = 7 End Function




Reply With Quote