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
;
|