Problems with

Blitz3D Forums/Blitz3D Programming/Problems with

asdfasdf(Posted 2006) [#1]
Oops! Forget to enter UDP in the Topic.
Im trying to write a program kind of like a proxy server. I can't seem to ever be able to connect. I ran a packet sniffer program while it was connecting and noticed that the source port is the same port that is in my program and the destination port is something really different. What is wrong? Thanks
AppTitle "FlightGear2FlightSimulator"

fgUDP = CreateUDPStream(5500)

fsUDP = CreateUDPStream(23456)

SendUDPMsg(fsUDP,DotToInt%("84.61.21.241"))

While Not KeyHit(1)

If RecvUDPMsg(fsUDP) Then
	Print ReadLine$(fsUD)
EndIf

WriteLine(fsUDP,Input$("")

Wend

Function DotToInt%(ip$)
	off1=Instr(ip$,".")	  :ip1=Left$(ip$,off1-1)
	off2=Instr(ip$,".",off1+1):ip2=Mid$(ip$,off1+1,off2-off1-1)
	off3=Instr(ip$,".",off2+1):ip3=Mid$(ip$,off2+1,off3-off2-1)
	off4=Instr(ip$," ",off3+1):ip4=Mid$(ip$,off3+1,off4-off3-1)
	Return ip1 Shl 24 + ip2 Shl 16 + ip3 Shl 8 + ip4
End Function



jfk EO-11110(Posted 2006) [#2]
sending a line every loop is a total overkill. Better use some pauses in this test.
the server side:
fsUDP = CreateUDPStream(23456)
SendUDPMsg(fsUDP,DotToInt%("84.61.21.241"))
While Not KeyHit(1)
 WriteLine(fsUDP,Input$("")
Wend

doesn't make sense. Instead use
fsUDP = CreateUDPStream(23456)
While Not KeyHit(1)
 WriteLine(fsUDP,Input$("")
 SendUDPMsg(fsUDP,DotToInt%("84.61.21.241"))
 delay 1000
Wend
closeudpstream (fsUDP)


And the client part has a little typo:
If RecvUDPMsg(fsUDP) Then
 Print ReadLine$(fsUD) ; <<<<<< use an existing stream
EndIf


Basicly I'd suggest to use ReadAvail(stream) and Readbytes instead. it won't wait for a linefeed. And for local test on one machine use localhost (127.0.0.1).