Need help with gnet

Blitz3D Forums/Blitz3D Programming/Need help with gnet

panton(Posted 2008) [#1]
I tested this code with my friend.
But he can't connect to my server!
What's wrong with this code:


Graphics 800,600,0,2

;ping!
Print "Ping:"+GNET_Ping()
Print ""

ListServers()


Function ListServers()
If Not GNET_ListServers("DeadEndOnline")
RuntimeError "Failed to list servers"
EndIf

Print LSet$("Game",16)+LSet$("Server",32)+LSet$("IP",16)
Print String$("-",64)
For t.GNET_Server=Each GNET_Server
Print LSet$(t\game$,16)+LSet$(t\server$,32)+LSet$(t\ip$,16)
If t\game$="DeadEndOnline"
If JoinNetGame("Ares01",t_ip$)<>0
playerID$=CreateNetPlayer("Player")

SendNetMsg 1,"Hallo!!",playerID$,"Server",0
Print "connected"
Else
RuntimeError "Can't connect"

EndIf
Endif
Next
Print ""
End Function

WaitKey()

Const GNET_HOST$="www.blitzbasic.com"
Const GNET_PORT=80
Const GNET_GET$="/gnet/gnet.php"

Type GNET_Server
Field game$,server$,ip$
End Type

Function GNET_Esc$( t$ )
t$=Replace$( t$,"&","" )
t$=Replace$( t$,"%","" )
t$=Replace$( t$,"'","" )
t$=Replace$( t$,Chr$(34),"" )
t$=Replace$( t$," ","_" )
Return t$
End Function

Function GNET_Open( opt$ )
t=OpenTCPStream( GNET_HOST$,GNET_PORT )
If Not t Return 0

WriteLine t,"GET "+GNET_GET$+"?opt="+opt$+" HTTP/1.0"
WriteLine t,"HOST: "+GNET_HOST$
WriteLine t,""

While ReadLine$(t)<>""
Wend

Return t
End Function

Function GNET_Exec( opt$,game$,server$ )
opt$=opt$+"&game="+GNET_Esc$(game$)
If server$<>"" opt$=opt$+"&server="+GNET_Esc$(server$)
t=GNET_Open( opt$ )
If Not t Return 0

ok=False
If( ReadLine$(t)="OK" ) ok=True

CloseTCPStream t
Return ok
End Function

Function GNET_Ping$()
t=GNET_Open( "ping" )
If Not t Return 0

ip$=ReadLine$(t)

CloseTCPStream t
Return ip$
End Function

Function GNET_AddServer( game$,server$="" )
Return GNET_Exec( "add",game$,server$ )
End Function

Function GNET_RefreshServer( game$,server$="" )
Return GNET_Exec( "ref",game$,server$ )
End Function

Function GNET_RemoveServer( game$ )
Return GNET_Exec( "rem",game$,"" )
End Function

Function GNET_ListServers( game$="" )
Delete Each GNET_Server
t=GNET_Open( "list" )
If Not t Return 0

Repeat
t_game$=ReadLine$(t)
If t_game$="" Exit
t_server$=ReadLine$(t)
t_ip$=ReadLine(t)
If game$="" Or game$=t_game$
p.GNET_Server=New GNET_Server
p\game$=t_game$
p\server$=t_server$
p\ip$=t_ip$
EndIf
Forever

CloseTCPStream t
Return 1

End Function


panton(Posted 2008) [#2]
Can anybody help me??!Plzz


CodeOrc(Posted 2008) [#3]
there is a problem with using gnet accross a network where the server is NOT in the DMZ.

something about directplay not being useful, u need to use UDP and/or TCP if I am not mistaken.