[Implemented] networking commands

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

[Implemented] networking commands

Post 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
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Perhaps in a userlib, but I wouldn't vote for this in the core PB language.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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 :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Several FTP clients are up over at the resources site now : http://www.reelmediaproductions.com/pb/
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post 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
Proteus
Enthusiast
Enthusiast
Posts: 113
Joined: Wed Sep 17, 2003 8:04 pm
Location: The Netherlands

Post 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.
P4 2.4GHz, 256 MB, WinXP Pro, onboard video&audio.
The Programmer's Drinking Song:
"99 little bugs in the code,
99 little bugs.
Fix one bug, recompile
100 little bugs in the code."
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post 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
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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.
Image Image
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

thanks i will try this out

Sean
oliv
User
User
Posts: 42
Joined: Sun Aug 24, 2003 10:11 am
Location: France

Post by oliv »

I have wrote a PureBasic DLL for FTP with windows api www.oliv.fr.fm but it is in french, sorry.
explications : http://perso.wanadoo.fr/pav-3dgc-origami/PB/FTP.htm
Download : http://perso.wanadoo.fr/pav-3dgc-origam ... es_FTP.dll
Post Reply