How to get an Answer from Server?
Blitz3D Forums/Blitz3D Beginners Area/How to get an Answer from Server?
| ||
This is how to get a message to the server using BNet (Blitz3D commands): First programm (SERVER): svrGame=CREATETCPSERVER(8080) IF svrGame<>0 THEN PRINT "Server erfolgreich gestartet" ELSE PRINT "Server konnte nicht gestartet werden" END END IF WHILE NOT KEYHIT(1) strStream=ACCEPTTCPSTREAM(svrGame) IF strStream THEN PRINT READSTRING$(strStream) DELAY 2000 END ELSE PRINT "Keine Daten mehr..." DELAY 1000 END IF WEND CLOSETCPSERVER svrGame END second programm (CLIENT): strmGame=OPENTCPSTREAM("127.0.0.1",8080) IF strmGame<>0 THEN PRINT "Client erfolgreich verbunden" ELSE PRINT "Konnte keine Verbindung herstellen" WAITKEY END END IF WRITESTRING strmGame,"Dieser Text wird übermittelt..." PRINT "Daten gesendet..." CLOSETCPSTREAM strmGame END What if you want to sent a message from Server to Client? Tried it several hours but failed, anyone could help please? |
| ||
The server communicates with the client in the same way the client does - that is, writing on the created TCP stream. I suggest you to check the code archive - there are rather good examples where to get infos from. I've also a complete multiclient tcp chat program that could help you : http://www.blitzbasic.com/codearcs/codearcs.php?code=28 Hope it helps, Sergio. |
| ||
Great, that Link explained it. Gracias... |