Repeat TCP information Sending

BlitzPlus Forums/BlitzPlus Beginners Area/Repeat TCP information Sending

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I recently began trying to create a program that could access my computer from any random other computer over the internet. However, whenever i opened up a TCP stream, it seems to only allow me a single "WriteLine FILE,str$" command before the stream terminates. So to bypass this i must close the old stream and open a new one. How do you bypass this inconvinience? It wouldn't be that bad if it didn't play havock with dos's "netstat" command, which i assume is a bad thing. Anyway here's the code below if it helps identify the problem.

-------------------------------------Server Code-------------------------------
Global fileout
Remote=CreateTCPServer(1026)

If Remote<>0 Then
Print "Server started successfully."
Else
Print "Server failed to initialize."
Delay(2000)
End
End If

Print "awaiting connection..."

While stream = 0
stream=AcceptTCPStream(Remote)
Wend

Compname$ = ReadString$(stream)

Print "Connected To Computer " + Compname + " at "
Print TCPStreamIP(stream)
fileout=WriteFile("C:\" + Compname + ".txt")

While Not KeyHit(1)
Stream=AcceptTCPStream(remote)
If Stream Then
Print ReadString$(stream)
WriteLine(fileout,ReadString$(stream))
End If
Wend

------------------------------------Remote Code---------------------------------
Global xdir2$ = ""
Global xdir
Global xname$ = "C:\"
Print "working..."
TCPHome=OpenTCPStream("192.168.1.102",1026)
WriteString TCPHome,GetEnv("computername")
;CloseTCPStream tcphome
Delay(1000)
If TCPHome <> 0
Delay(100)
xdir = ReadDir(xname$)
Repeat
FILE=OpenTCPStream("192.168.1.102",1026)
xdir2$=NextFile$(xdir)
If xdir2 = "" Then Exit
If FileType(xname$+"\"+xdir2) = 2
WriteString FILE,("Folder: " + xname$ + xdir2)
Else
WriteString FILE,("File: " + xname$ + xdir2)
End If
Delay(100)
CloseTCPStream FILE
Forever
EndING=OpenTCPStream("192.168.1.102",1026)
WriteString EndING,"Program Successfully Executed. Exiting Now"
End If

CloseTCPStream tcphome
CloseTCPStream ending

Print "done!"

I use port 1026 to bypass the WinXP firewall.