[Gambas-user] Trouble writing to Accepted Socket stream

T Lee Davidson t.lee.davidson at gmail.com
Sat Mar 30 08:31:33 CET 2019


On 3/29/19 8:38 PM, Jussi Lahtinen wrote:
> MySock_Ready, instead of Socket_Ready?

Huh? No, not MySock_Ready -  MySock_Connection and Socket_Ready.

> Why there is out commented write in read event?

The commented Write is to show that the Socket_Write event is not triggered until a Write #Stream is actually attempted which I 
do after the Stream is read. All you have to do is uncomment it instead of typing in a Write statement.


[snip]
> 
>     Public Sub MySock_Connection(RemoteHostIP As String)
> 
>         MyConn = hServerSocket.Accept()
> 
>     End
> 
>     Public Sub Socket_Ready()
> 
>         Print "Socket READY."
> 
>     End
> 
>     Public Sub Socket_Read()
> 
>         For Each sLine As String In MyConn.Lines
>           Print sLine
>         Next
> 
>         ' Print "Writing to stream."
>         ' Write #MyConn, sResponse, Len(sResponse) 'Socket not ready for writing until here.
> 
>     End
> 
>     Public Sub Socket_Write()
> 
>         Print "Socket ready for writing."
>         ' Inc Count
>         ' Print Count
>         ' Write #MyConn, sResponse, Len(sResponse) 'Nearly endless loop created here.
> 
>     End
[snip]


More information about the User mailing list