Need help--stumped on why this locks up.

BlitzMax Forums/BlitzMax Programming/Need help--stumped on why this locks up.

sean916(Posted 2014) [#1]
I have a server/client that works fine and messages can be sent back and forth without issue. But whether I use maxgui or simply create a window and output with text, the window will freeze (network traffic works fine). I cannot figure it out for the life of me.

If I don't call the tcp_in function the window works fine, but then obviously I cant read incoming messages.




xlsior(Posted 2014) [#2]
IIRC readline is a blocking operation: it will sit there and wait for an end-of-line character to come by before it continues.

You either need to check that there's anything waiting in the stream before initiating your readline, or (more complicated) rewrite your program so it's multithreaded and put the communication functions in their own thread.


sean916(Posted 2014) [#3]
That makes sense. In blitzbasic you could do an "if readavail" to check to see if anything had come in. I have not seen a corollary in blitzmax. Do you have any suggestions?


sean916(Posted 2014) [#4]
Got it working, thanks for putting me on the right track. SocketReadAvail is functionally equivalent. I wonder why they changed that it Max *shurgs*