Tcp Stream Problem

Blitz3D Forums/Blitz3D Programming/Tcp Stream Problem

msx123(Posted 2005) [#1]
Hi!

I have a little problem. I have making a program that comunicate with other program (make in other language) via TCP/IP Stream.

My program is client of this program (this program is server).

Well, I use OpenTCPStream, but ...

Is possible to know if the server has sended a messsage?

Example:

tcpstream = OpenTCPStream(ip,port)

; Check if server send a message

How?

If I use ReadByte(stream), have a problem:

a) If server don't send message, timeout.
b) If server send a message, lost this byte.

And ... ReadAvail ... (works) or is only for check all bytes sended?

I need frame to frame if server send a message ... :/


KuRiX(Posted 2005) [#2]
Check for ReadAvail...

And if you want a blocking function

while (readavail(stream) = 0)
Wend

or better

while (readavail(stream) < WaitingSize)
Wend


msx123(Posted 2005) [#3]
Thanx for your reply Kurix.

But ReadAvail is 0. Always. And the buffer is filled, or if the buffer is empty. Always 0.

That's is the problem! :(


KuRiX(Posted 2005) [#4]
MAke sure tcpopenstream returns non zero, then make sure you are sending something!


msx123(Posted 2005) [#5]
Oooooooooooooooopsss!!!


Sooooooooooooooooooryyyyyyyyyyy!! ReadAvail works fine!!!


Is MY problem. Sorry and Thanx Kurix! ;)