Re: [Gambas-user] Nested Socket Write does not work

2009-03-06 Thread Ron_1st
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

-- 


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Nested Socket Write does not work

2009-03-06 Thread Benoît Minisini
>
> Sorry, I don't know how gambas works with sockets, but instead I noticed
> something else that perhaps is worth to be investigated. When you write
> on socket, you send something like "[0]text". The length of this example
> string is 7 characters, but your formula gives 8 because you add 4 to
> the length of the original text. Perhaps, this code tries to access past
> the end of the string. In other languages this could lead to an
> exception - don't know what happens in gambas: who knows... may be it
> does strange things...
>

It is not a problem. The real length of the string is used then.

-- 
Benoît


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Nested Socket Write does not work

2009-03-06 Thread Doriano Blengino
CARLOS GTR ha scritto:
> 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.
>   
Sorry, I don't know how gambas works with sockets, but instead I noticed 
something else that perhaps is worth to be investigated. When you write 
on socket, you send something like "[0]text". The length of this example 
string is 7 characters, but your formula gives 8 because you add 4 to 
the length of the original text. Perhaps, this code tries to access past 
the end of the string. In other languages this could lead to an 
exception - don't know what happens in gambas: who knows... may be it 
does strange things...

Regards,
Doriano


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Nested Socket Write does not work

2009-03-05 Thread Benoît Minisini
> 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

Can you give more details? Which version of Gambas do you use? Can you send 
the source code of the client and the server ?

-- 
Benoît


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] Nested Socket Write does not work

2009-03-04 Thread CARLOS GTR
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

-- 
Nx GTR
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user