Page 1 of 1
[Implemented] networking commands
Posted: Thu Dec 11, 2003 4:40 am
by scurrier
more commands to do netoworking stuff
like:
ConnectFTP (Servername,username,password,port)
DownloadFTP(Servername,path+filename,port)
UploadFTP(Servername,path+filename,port)
DeleteFTP(Servername,path+filename,port)
MkdirFTP(Servername,path+filename,port)
TotalFiles=TotalFilesFTP(Servername,path)
for x=1 to TotalFiles
file$(x)=DirFTP(Servername,path,port)
next x
and can do the same for www or http servers
to get all the files and directorys on an FTP server at certin start point
these would be very handy and wouldn't need the windows API, and make it more portable between linux, amiga, and windows
if anyone could think of anything else network wise please add it in
Sean
Posted: Thu Dec 11, 2003 2:17 pm
by Karbon
Perhaps in a userlib, but I wouldn't vote for this in the core PB language.
Posted: Thu Dec 11, 2003 4:41 pm
by blueznl
i agree with karbon
i could imagine some 'socket' commands though, that might make sense, but a complete protocoll might be over the edge... it's fred's call though

Posted: Thu Dec 11, 2003 6:32 pm
by Karbon
Several FTP clients are up over at the resources site now :
http://www.reelmediaproductions.com/pb/
Posted: Fri Dec 12, 2003 5:00 am
by scurrier
i have tried all the example ftp clients and they all use winapi
i think there should be built in commands to do this or user libs
not the api, cause then it's not portable to linux or amiga
Sean
Posted: Fri Dec 12, 2003 2:03 pm
by Proteus
You can do it without API.
There is a example of an FTP server in PB that doesn't use WinAPI. I think if a server can be built without using API, a client can be built without it as well.
Posted: Sat Dec 13, 2003 3:08 am
by scurrier
show me an example of how to connect to an ftp server and send username and password without the use of windows API i have tried and can't figure it out. when i connect using the network commands built into pb i have know idear if it works cause an ftp server doesn't send me any onfo back if it failed or not if you can send me a snipit of connecting to and ftp and sending a file or getting a file that would be great but do it without the ftp commands in the windows API
Posted: Sat Dec 13, 2003 7:40 am
by Paul
Ok, in it's simplest form... this code will connect to an FTP server and login with user name and password. No API
Code: Select all
#Window_Main=0
#Gadget_Main_Info=1
IP.s="ftp.reelmediaproductions.com"
port.l=21
Procedure send(hNet,msg$)
SendNetworkData(hNet,@msg$,Len(msg$))
EndProcedure
Procedure wait(hNet)
AllocateMemory(0,1000,0)
length=ReceiveNetworkData(hNet,UseMemory(0),1000)
ProcedureReturn UseMemory(0)
EndProcedure
Procedure.l Window_Main()
If OpenWindow(#Window_Main,175,0,351,216,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,"FTP Test")
If CreateGadgetList(WindowID(#Window_Main))
EditorGadget(#Gadget_Main_Info,0,0,350,215)
HideWindow(#Window_Main,0)
ProcedureReturn WindowID()
EndIf
EndIf
EndProcedure
;--------------------
If InitNetwork()
hNet=OpenNetworkConnection(IP,port)
If hNet
Window_Main()
AddGadgetItem(#Gadget_Main_Info,-1,PeekS(wait(hNet)) )
Delay(100)
send(hNet,"USER guest"+Chr(13)+Chr(10))
AddGadgetItem(#Gadget_Main_Info,-1,PeekS(wait(hNet)) )
Delay(100)
send(hNet,"PASS guest"+Chr(13)+Chr(10))
AddGadgetItem(#Gadget_Main_Info,-1,PeekS(wait(hNet)) )
Delay(100)
send(hNet,"QUIT"+Chr(13)+Chr(10))
AddGadgetItem(#Gadget_Main_Info,-1,PeekS(wait(hNet)) )
CloseNetworkConnection(hNet)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Else
MessageRequester("Connection Error","Could Not Connect to FTP Server",#MB_ICONERROR)
EndIf
Else
MessageRequester("Error","Could Not Initialize Network",#MB_ICONERROR)
EndIf
End
Of course to do things properly, you can't be lazy... you must read up on the FTP protocol, add error checking, proper event checking, etc.
This is only a very simple example to do what you asked.
Posted: Sun Dec 28, 2003 4:06 am
by scurrier
thanks i will try this out
Sean
Posted: Sat Jan 31, 2004 12:04 pm
by oliv