Author Topic: Network help  (Read 3533 times)

Offline acristo

  • Mr. Drawsprite
  • **
  • Posts: 51
    • View Profile
Network help
« on: 2008-May-23 »
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
« Last Edit: 2008-May-23 by acristo »

Offline acristo

  • Mr. Drawsprite
  • **
  • Posts: 51
    • View Profile
Re: Network help
« Reply #1 on: 2008-May-23 »
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...

Offline acristo

  • Mr. Drawsprite
  • **
  • Posts: 51
    • View Profile
Re: Network help
« Reply #2 on: 2008-May-26 »
So, can anyone help me ?

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
Re: Network help
« Reply #3 on: 2008-May-27 »
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", "","")


Offline acristo

  • Mr. Drawsprite
  • **
  • Posts: 51
    • View Profile
Re: Network help
« Reply #4 on: 2008-May-29 »
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...
« Last Edit: 2008-May-29 by acristo »

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1793
    • View Profile
    • Homepage
Re: Network help
« Reply #5 on: 2008-May-29 »
The client/server was in the german forum but I can't find it either right now