Network help

Previous topic - Next topic

acristo

Can anyone help with this piece of code ?

Why it is not allocating any resource ?

Code (glbasic) Select
GLOBAL timer, ntimer
GLOBAL elapsed = 10
GLOBAL a$

AUTOPAUSE FALSE
GLOBAL scy=600

ok=NETHOSTGAME(0,0, "127.0.0.1","")


IF ok=TRUE
a$= "Network on. Last check at"
myplayer$ = NETCREATEPLAYER$("Admin")
ELSE
a$= "Network off. Last check at"
ok=NETHOSTGAME(0,0, "","")
ENDIF

ips$ = NETGETIP$()
num = SPLITSTR(ips$, ip$[], "|")

WHILE TRUE

FOR i=0 TO num-1
    PRINT "IP: "+ ip$[i], 0, scy-((i+1)*20)
NEXT

timer = INTEGER((GETTIMERALL())/1000)
PRINT "Elapsed time " + timer,0,20

IF elapsed - timer = 0
elapsed =(INTEGER((GETTIMERALL())/1000))+10
TestNet()
ELSE
PRINT a$ +" "+ ntimer,0,0
ENDIF
PRINT "Network"+ok,0,40
PRINT "Admin= "+myplayer$,0,60

  SHOWSCREEN

WEND

Code (glbasic) Select

FUNCTION TestNet:

ntimer=INTEGER((GETTIMERALL())/1000)

IF ok=TRUE
a$="Network on. Last check at"
ELSE
a$="Network off. Last check at"
ENDIF

ENDFUNCTION

acristo

Maybe I'm still missing some understanding how GLbasic works when dealing with networks... i just noticed that on the code above glbasic alloc the network resources, releasing it after few seconds.. why ? what should be done to keep the resources allocated, I mean the service online...

acristo

So, can anyone help me ?

Maxheadroom

my be its because you are using a loop back address

ok=NETHOSTGAME(0,0, "127.0.0.1","")

should it not be

ok=NETHOSTGAME(0,"mygame-name", "","")


acristo

#4
I tryied both, no success.. I believed I ran over some client server somewhere in the forum, but i don't remember where was it...

Moru

The client/server was in the german forum but I can't find it either right now