tcp grief

BlitzPlus Forums/BlitzPlus Programming/tcp grief

El Neil(Posted 2007) [#1]
this code works fine on my own pc, with the server code running in another instance of b+. however, as soon as i run it on another machine and enter the external IP, it cannot find the server. any ideas as to what im doing wrong?

cheers

neil



this is the client code



;

Print "Enter IP address of server"
Print "Default: 127.0.0.1"

Global ip$ = Input("")
If ip="" Then ip = "127.0.0.1"
Global port = 8222
Global clientname$ 





Repeat 
clientname = Input("What's your name? ")
Until clientname<>""





saytcp(clientname +" has joined",1)
Print "Chat opened on port "+port
Print ""




Repeat

	saytcp(Input("type something to send: "),0)

Forever





Function saytcp(msg$,breed)



	msgout$ = ""

	If breed = 1 Then msgout = msgout + "**** "
	If breed = 0 Then msgout = msgout + clientname + ": '"

	msgout = msgout + msg

	If breed = 1 Then msgout = msgout + " ****"
	If breed = 0 Then msgout = msgout + "'"


	serverstream = OpenTCPStream(IP,port)




	If serverstream Then 

		WriteString(serverstream,msgout)
		WriteString(serverstream,"")


	Else

		RuntimeError "Couldn't open a tcp stream on port "+port
	
	End If



End Function



;



and this is the server code...



;

Global clock = CreateTimer(3)
Global port = 8222
Global potential$




Global server = CreateTCPServer(port)



If server <> 0 Then 

	Print "Server created on port "+port
	Print ""

Else

	RuntimeError "Could not create server on port "+port

End If






; @@@@@@@@@@@@@@@@@@@@@ MAIN LOOP @@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@ MAIN LOOP @@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@ MAIN LOOP @@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@ MAIN LOOP @@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@ MAIN LOOP @@@@@@@@@@@@@@@@@@@@@@@@@



Repeat

	potential = AcceptTCPStream(server)
	If potential <>0 Then Print Str(ReadString$(potential))







	WaitTimer(clock)


Forever



;



Xzider(Posted 2007) [#2]
If you have a router you must forward the ports... Google Port Forwarding


El Neil(Posted 2007) [#3]
aha, thank you!

neil


Xzider(Posted 2007) [#4]
No problem, if you run in to any trouble, let me know. I had a linksys router I forwarded them all the time, just got a netgear (I am starting to like netgear, this one has LED lights,and a better router config,much smaller then linksys, and I got the one with the best range/speed)