Rottnet problem
Blitz3D Forums/Blitz3D Programming/Rottnet problem
| ||
Hi. I got a few problems getting ROTTNet to work. The samples work fine, but my own code fails to run. (I can create the server and join it locally, but I can't join a running server from another instance of my app. It timeouts.) The network code so far is displayed below ; Network code ; Are we the server? Global Net_I_Am_Server = False ; Net client/server handles Global Net_Server_Handle Global Net_Client_Handle ; Start network Function Net_StartServer() Net_I_Am_Server = True Net_Server_Handle = RN_StartHost(CFG_SERVERPORT, "", CFG_MAXPLAYERS, CFG_SERVERLOG) If Net_Server_Handle = 0 RuntimeError("Could not start server on port " + CFG_SERVERPORT) End If HUD_AddConsoleLine("Server started on " + CFG_SERVERIP) End Function ; Start client Function Net_StartClient() ; Set clientport + server port + 1 ClientPort% = CFG_SERVERPORT + 1 ; If we're the server bump client port one up If Net_I_Am_Server ClientPort = ClientPort + 1 End If ; Attempt connection Net_Client_Handle = RN_Connect(CFG_SERVERIP, CFG_SERVERPORT, ClientPort, CFG_NAME, "", CFG_CLIENTLOG) Select Net_Client_Handle Case RN_PortInUse : RuntimeError "Port " + ClientPort + " already in use!" Case RN_HostNotFound : RuntimeError "Server not found!" Case RN_TimedOut : RuntimeError "Server did not respond within reasonable time" Case RN_ServerFull : RuntimeError "Server full" End Select ; Tell user if not server If Not NET_I_Am_Server HUD_AddConsoleLine("You joined the server") End If End Function ; Update networking Function Net_Update() ; Parse messages For M.RN_Message = Each RN_Message Select M\MessageType ; Host left! Case RN_HostHasLeft RuntimeError "Connection to server lost!" ; Player joined Case RN_NewPlayer HUD_AddConsoleLine("" + RN_PlayerName$(Net_Server_Handle, M\FromID) + " joined game from " + DottedIP(RN_PlayerIP(Net_Server_Handle, M\FromID))) End Select Delete M Next End Function For the record I did consider using BlitzNet which comes with a much more elaborate example, but the lack of guaranteed delivery makes it a nogo. (Well, the free one does anyway :) |