vb.net socket programming

G

Guest

Hi guys please help i'm really stuck.

I'm trying to upload a file from a pcket pc 2003 to a passworded ftp site.
I've tried wininet and its useless so i'm programming my own socket client.

I initialise a connection, and log on over the ftp control socket no problem
but i'm stuck as to how i get the data connection going. Please help, i've
searched for days and can find nothing. Here's what i've got so far having
logged on successfuly:

public sub upload(sFileName as string)

cSocket = CreateDataSocket()

SendCommand("STOR " & "file1.txt")

'read the file into bytes
Dim reaa As System.IO.FileInfo
reaa = New System.IO.FileInfo(sFileName)
Dim oFileStream As System.IO.FileStream = reaa.OpenRead()
Dim lBytes As Long = oFileStream.Length
Dim fileData(lBytes) As Byte
oFileStream.Read(fileData, 0, lBytes)
oFileStream.Close()

cSocket.Send(fileData)

readline()
end sub

Private Function CreateDataSocket() As Socket
s = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)

ep = New IPEndPoint(Dns.Resolve(FRemoteHost).AddressList(0),
FRemotePort)
Try
s.Connect(ep)
Catch ex As Exception
Throw New IOException("Can't connect to remote server")
End Try

Return s

End Function


This produces:

1) after STOR command the file is created on the ftp server and this
repsonse is read from the server(which i think is normal):
"230 User upload logged in.
150 Opening ASCII mode data connection for file1.txt.
"
2) Then right after i send the cSocket.Send(fileData) command i get this
response:
"425 Can't open data connection.
"

Please any suggestions would be appreciated so much. Thanks for your time

Jimbo.
 
G

Guest

Hey chris

that site is really confusing! i don't know what to download!

All i need to do is upload a file, what do i have to donwload.

thanks very much
 
G

Guest

It's going to be even more confusing since the FTP stuff isn't yet released.
You'll have to pull each file from source control. You can do it by
installing the Sourcegear Vault client[1] or using the web interface[2].
Once you have the files, just add them to your project and you're good to
go.

-Chris

[1] http://sourcegear.com/vault/downloads.html
[2] http://vault.netcf.tv/VaultService/VaultWeb/login.aspx
uid: guest pwd: guest
$\OpenNETCF\SDF\OpenNETCT.Net\FTP
You'll need all 5 files
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top