Client & Server

BlitzPlus Forums/BlitzPlus Beginners Area/Client & Server

Kirkkaf(Posted 2011) [#1]
Hi everyone,

I am just playing around with some of the network commands and have come to a halt. I worked of the example in the documentation which has been great help.

I can successfully send a message from client to server. However I can only send 1 message before the server seems to just freeze up.

I would appreciate if someone could point out where I've gone wrong.

SERVER:
Server = CreateTCPServer(6000)

If Server Then 
	Print("Server has been succesfully created.")
Else
	Print("Server has failed to be created.")
EndIf 

Repeat 
	Connection = AcceptTCPStream(Server)

	If Connection Then 
		Print(ReadString(Connection))
	EndIf
Forever 


CLIENT:
Client = OpenTCPStream("127.0.0.1", 6000)

If Client Then 
	Print("Connected to server.")
Else
	Print("Unable to connect to server.")
EndIf 

Repeat 
	msg$ = Input()
	WriteString(Client, msg$)
Forever 


Thanks for taking the time to look at this.


Kirkkaf(Posted 2011) [#2]
Anyone got any ideas?


Mahan(Posted 2011) [#3]
Take a look at the ReadAvail command. If you try to read from a socketstream and the data is not there (yet?) your ReadString() (or other read command) will freeze the program.


Kirkkaf(Posted 2011) [#4]
Thank you for this information I will give it ago.