TCP Networking Help

Blitz3D Forums/Blitz3D Beginners Area/TCP Networking Help

I'm kinda new to the whole networking thing and I am trying to make a internet game.

my code:

it connects via this function:
host=Input ("1-Host,2-join")

If host=1

Print "Creating Server on port 8080"

svrgame=CreateTCPServer(8080)
Print "Server Started Succesfully"

Delay 500

Else

Print "Joining..."

svrstrm=OpenTCPStream("127.0.0.1",8080)

Print "Stream Connected"

EndIf 


here's where it transfers data.
If host=2

;Read Streams
strm=AcceptTCPStream(svrstrm)   ;ERROR RIGHT HERE

If strm Then 
plx#=ReadFloat#(strm)
ply#=ReadFloat#(strm)
plz#=ReadFloat#(strm)
plyaw=ReadLine(strm)
plpitch=ReadLine(strm)
plroll=ReadLine(strm)
CloseTCPStream strm
EndIf 

;CloseTCPStream(svrstrm)

wrtstrm=OpenTCPStream("127.0.0.1",8080)

;Write Stream
For p.pl=Each pl 
WriteFloat(wrtstrm,EntityX(p\cam))
WriteFloat(wrtstrm,EntityY(p\cam))
WriteFloat(wrtstrm,EntityZ(p\cam))
WriteInt(wrtstrm,EntityYaw(p\cam))
WriteInt(wrtstrm,EntityPitch(p\cam))
WriteInt(wrtstrm,EntityRoll(p\cam))
DebugLog "Sent"+wrtstrm
Next 

CloseTCPStream(wrtstrm)

Else ;if hosting

;Read Streams
strm=AcceptTCPStream(svrgame)

If strm Then 
plx#=ReadFloat#(strm)
ply#=ReadFloat#(strm)
plz#=ReadFloat#(strm)
plyaw=ReadLine(strm)
plpitch=ReadLine(strm)
plroll=ReadLine(strm)
CloseTCPStream strm
EndIf 


wrtstrm=OpenTCPStream("127.0.0.1",8080)

;Write Stream
For p.pl=Each pl 
WriteFloat(wrtstrm,EntityX(p\cam))
WriteFloat(wrtstrm,EntityY(p\cam))
WriteFloat(wrtstrm,EntityZ(p\cam))
WriteInt(wrtstrm,EntityYaw(p\cam))
WriteInt(wrtstrm,EntityPitch(p\cam))
WriteInt(wrtstrm,EntityRoll(p\cam))
DebugLog "Sent"+wrtstrm
Next 

CloseTCPStream(wrtstrm)

EndIf 



Both of those code are in functions and just about every variable is Global.
I run a host program for my first instance and it works fine, then I run a second instance and it connects but gives me the error "Stream Does not Exist" at
strm=AcceptTCPStream(svrstrm) 


(I marked it with an all caps error comment)

Why is it giving me this error? Thanks