Code archives/Networking/saving files on a remote system
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
| This is just some simple code showing how to save a file over the internet, it's pretty simple I just figured someone new might need it. If you use it as help and make somthing let me know please I would like to see whats made from this method. Just paste the server part into a bb and same as client but make sure its in a seperate file. | |||||
;---------------------------SERVER--------------------------
;small example on how to write to files over the net
;BY:Ckob
mainsvr=CreateTCPServer(8080) ;create the server
If mainsvr<>0 Then
Print "Server started successfully."
Else
Print "Server failed to start."
End
End If
While Not KeyHit(1)
strStream=AcceptTCPStream(mainsvr)
If strStream Then
msg$ =ReadString$(strStream)
Print msg$
Delay 2000
fileout = WriteFile("example.dat")
WriteLine( fileout, msg$ )
CloseFile(fileout)
Else
Print "No message has been recieved yet yet"
Delay 1000
End If
Wend
End
;-----------------------------------------------------------
;---------------------------Client--------------------------
;small example on how to write to files over the net
;BY:Ckob
mainsvr=OpenTCPStream("127.0.0.1",8080)
If mainsvr<>0 Then
Print "Client Connected successfully."
Else
Print "Server failed to connect."
WaitKey
End
End If
name$ = Input("Name: ")
FlushKeys
; write stream to server
WriteString mainsvr,name$
;----------------------------------------------------------- |
Comments
| ||
"ckob's" code archive will serve as his shrine.![]() Our Pal 18th November 1981 to 7th June 2008. |
| ||
| Why yes...yes it will puki. |
Code Archives Forum
