[Gambas-user] Net Socket timing issue?

Daniel Campos daniel.campos at ...338...
Sat Jan 15 20:09:36 CET 2005


ericbudd at ...407... escribió:

>I tried your suggestion, which was interesting, because Ihad been concentrating on the "read" portion of the code.  HoweverI am still having the problem.  I did discover something interesting that may make it easier, tho...
>
>In my socket wrapper class, I have the following code on the MySocket_Read event:
>
>  READ #sM, LastBuf, Lof(sM)
>  frmMain.txtConsole.Text = frmMain.txtConsole.Text & LastBuf
>
>On the frmMain, the button which sends the command has the following code:
>
>  sockMUSH.Write(ME.txtCommand.Text & Chr(10))
>  txtConsole.Selection(Len(txtConsole.Text), 0) ' this line moves to the bottom of the display area
>
>  So the button is clicked, the command is written, the console is correctly updated, but not until AFTER the selection command.  The code finishes executing before any data comes back on the port.
>
>  Is there a way I can force the program to wait until a read has occurred and finished before continuing?
>
>Thanks so much!
>
>
>  
>
The Socket class is non-blocking, so the only way to wait is writting a 
loop:

Do While Lof(sM)=0
    WAIT (0.1)  ' or the time you want :-)
Loop

Regards,

D. Campos







More information about the User mailing list