ReadLine Problems

BlitzMax Forums/BlitzMax Programming/ReadLine Problems

foosh(Posted 2008) [#1]
So here is the basic setup: I have a Python server, that when the command "curmap//" is sent, it sends back the coordinates of all players attached to the server. It does this in the main game loop, like so:
While Not KeyDown(Key_ESCAPE)
	network.updateMap()
Wend


For some reason, in the updateMap() method, it freezes at print ReadLine(stream). Any idea why? I've checked, and the server is properly fulfilling the request...

Method updateMap()
	Local dataSend:String
	Print "Requesting data..."
	dataSend = "curmap//"
	Print "Sending request..."
	WriteLine(stream,dataSend)
	Print "Retrieving data..."
	Print ReadLine(stream)
End Method


Thanks!
foosh


TomToad(Posted 2008) [#2]
If I'm not mistaken, ReadLine() will block until an entire line of text is read, i.e. recieves a CR or LF. So you would need to send "curmap//~n"


GfK(Posted 2008) [#3]
You should also check that there's is something in the stream to be read before actually reading it.