[Gambas-user] Nested Socket Write does not work

Ron_1st ronstk at ...239...
Fri Mar 6 13:09:08 CET 2009


On Thursday 05 March 2009, CARLOS GTR wrote:
> Hi, I am working in chat program in Gambas that works with TCP sockets.
> The problem is that the clients that connect to the server need to receive
> the list of the contacts that are online (as any chat), The Server has the
> list but cant send it.
> 
> This is the code:
>    DIM y, x AS Integer
>    FOR x = 0 TO Client.Max
>       FOR y = 0 TO listacontactos.Count - 1
>          ' Message(“dgdsgfds”) If I uncomment this line everything works
>          WRITE #Client[x], "[" & y & "]" & listacontactos[y].Text,
> Len(listacontactos[y].Text) + 4
>       NEXT
>    NEXT
> 
> That code with the message instruction commented only send 1 contact, when I
> uncomment that dummy message line everything works perfect.
> 
> Another interesting fact is that If I put break points for the nested FORs
> and see what happens the programs runs perfect even without the dummy
> message instruction.
> 
> Hope somebody could help. Thanks in advance
> 

What happens if listacontactos.Count is 200 items?

You do Len(listacontactos[y].Text) + 4 but that does not fit for item 100

DIM y, x AS Integer
DIM towrite AS String
FOR x = 0 TO Client.Max
  FOR y = 0 TO listacontactos.Count - 1
   ' Message(“dgdsgfds”) If I uncomment this line everything works
    towrite="[" & y & "]" & listacontactos[y].Text
    WRITE #Client[x], towrite , Len(towrite)
  NEXT
NEXT

would do the job more correct.


Best regards,

Ron_1st

-- 





More information about the User mailing list