Ok i did a search around this place and i could not find a single location on how to make a FTP SERVER. I'm not looking for anything all to fancy. 1 user capacity, able to get the Drive tree, download/upload, etc. Does anyone know of any pages that may have this type if infromation on it? Or, could they try and send me the coding for this?
If you want to make a FTP Server than your server must communicate with the client in FTP (offcoarse). To do that just setup a winsock control on port number 21(that's the standard FTP port) on your server, then learn the FTP protocol so that you know how to communicate with the cilent (in FTP) and do all your basic commands. Easy, Right?
I know the FTP codes...
but how do you make the server (in coding form)?
Becuase im kinda new to Vb.... err strike that...
I VERY NEW to Vb programming (THERE I admited it ok. Are you happy now?), and you are skiping over my question. Is there anypages in here that will show, step by step? Like i said, im fimilar with the commands and the port numbers and how to tune a client/server to listen for thouse comands.
I can ever make it (sorta) connect.
winsock.localport(21)
winsock.listen
Something along the lines of that (kinda going of the top of my head). But after that.... whats next?
Private Sub Form_Load()
Winsock.LocalPort = 21 'Ftp's standard Prot
Winsock.Listen
End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Winsock.Close
Winsock.Accept requestID
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Winsock.GetData s
'You can now parse s to get ftp commands
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock.Close
Winsock.LocalPort = 21 'Ftp's standard Prot
Winsock.Listen
End Sub
Private Sub Winsock_Close()
Winsock.Close
Winsock.LocalPort = 21 'Ftp's standard Prot
Winsock.Listen
End Sub
_________________
This piece of code will only help in handling one request at a time. For multiple requests, use multiple winsock controls
When i copy and paste the code into VB and i try and run it (i put the little winsock icon in the form window before i did though). It gives me the error: Varable not defined. And it points to.... Private Sub Form_Load()
But it Highlights Winsock (not in yellow, but in blue)
next thing
Explane to me like im an idoit (which shouldn't be to hard) on what next i should do? The Phase S part.
Yeah, that is because when you put that little icon in the Form, it's default name is Winsock1, and in my code it's written Winsock. You can just change the name of the control in the form. And note that my code is just an example, it will have many problems if you use this code in an application. And remenber, you also have to parse the variable 's' to figure out commands. And one more thing, it can handle only 1 request at a time, if another PC tries to connect, the current session will be terminated and the new one will start.
told ya i was a beginner..
now i got it to recive commands... but my server has no idea what they mean...
That i will working (with many trips here along the way).
I under stand that it can only handle 1 connection. I only want 1 connection anyways. So how do make it to stop listening to that port once a computer is connected?
Change the Listening port to something like 22 after the client has connected? Or will that disconnect the computer/client on the port 21 allready? I want to make it compleatly unavailable (if possable) to the outside world once something connects to it.
Also what do you mean the "phase" something (i get where the varable s comes from).
Boy, after reading my messages i just realized that i probaly have worst english in the world (or probaly just this form). Gezzz i need to learn to proof read my messages before i send them out.
Private Sub Form_Load()
Winsock.LocalPort = 21
Winsock.Listen
End Sub
Private Sub Winsock_Close()
Winsock.Close
End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Winsock.Close
Winsock.Accept requestID
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Winsock.GetData s
Select Case UCASE(s)
Case "LIST"
'you can do whatsoever
Case "CDUP"
'you can do whatsoever
End Select
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock.Close
End Sub
__________________
This will only accept 1 connection. After that session is over, it will not accept anymore connections. I've also showed an example of how to parse.
The request ID is a number that helps the Visual Basic to keep track of all its requests. All you have to do is accept the Id that is requesting the connection. If you want to know th Ip address of the person requesting the Connection:
1) Accept the ID
2) Type:
MsgBox Winsock.RemoteHostIP
that will tell you the person's ip. If you dont want that person to connect reset the connection:
Winsock.Close
Winsock.LocalPort = 21
Winsock.Listen