Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: Short cut icons on a windows form Pin
Anonymous5-Jun-05 19:29
Anonymous5-Jun-05 19:29 
GeneralExchange the Language on a localized Windows Forms form Pin
Uwe Keim4-Jun-05 20:30
sitebuilderUwe Keim4-Jun-05 20:30 
Generalpls Provide C# code for the Visual Basic code Below Pin
monica2k4-Jun-05 18:00
monica2k4-Jun-05 18:00 
GeneralRe: pls Provide C# code for the Visual Basic code Below Pin
Chris Austin4-Jun-05 19:33
Chris Austin4-Jun-05 19:33 
GeneralRe: pls Provide C# code for the Visual Basic code Below Pin
WillemM5-Jun-05 0:58
WillemM5-Jun-05 0:58 
GeneralRe: pls Provide C# code for the Visual Basic code Below Pin
Robert Rohde5-Jun-05 1:39
Robert Rohde5-Jun-05 1:39 
GeneralRe: pls Provide C# code for the Visual Basic code Below Pin
Michael P Butler5-Jun-05 3:44
Michael P Butler5-Jun-05 3:44 
GeneralC# Active FTP Data Transfer Pin
eddieg764-Jun-05 17:21
eddieg764-Jun-05 17:21 
I have a project where I must send data to a remote FTP server using an Active FTP connection. I'm able to connect to the remote server fine, but when I send the "POST" command, the socket is not connecting. I get the following exception error:

"A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied"

I have looked all over the net for an example of sending the FTP "POST" command, but haven't found anything. What am I doing wrong? Working examples would be greatly appreciated.

Here's the code snippet I'm trying to use (let me know if you need more information):

private string GetPortParameters(int localPort)
{
string localHost = Dns.GetHostName();
IPAddress localIPAddress = Dns.Resolve(localHost).AddressList[0];
string strLocalIPAddress = localIPAddress.ToString();
strLocalIPAddress = strLocalIPAddress.Replace('.',',');
int portParam1 = ( 0xff00 & localPort ) >> 8;
int portParam2 = ( 0xff & localPort ) ;

string portParameters = strLocalIPAddress + "," + portParam1 + "," + portParam2;
return portParameters;
}

private int GetPort()
{
if ( dataPort > 30000 )
{
dataPort = 10000;
}
return dataPort++;
}
private Socket CreateActiveDataSocket()
{
int thePort = GetPort();
string portParams = GetPortParameters(thePort);
Socket portSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
IPEndPoint ep = new IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList[0], thePort);
portSocket.Bind(ep);
portSocket.Listen(4);
SendCommand("PORT "+portParams);
SendCommand("STOR "+Path.GetFileName("C:\\somefilename.txt"));
portSocket.Accept();
// sending the socket back to the caller to transfer (upload) the file
return portSocket;
}

Eddie
GeneralRe: C# Active FTP Data Transfer Pin
WillemM5-Jun-05 0:29
WillemM5-Jun-05 0:29 
GeneralRe: C# Active FTP Data Transfer Pin
emgeed6-Jun-05 14:48
emgeed6-Jun-05 14:48 
GeneralRe: C# Active FTP Data Transfer Pin
WillemM6-Jun-05 20:38
WillemM6-Jun-05 20:38 
GeneralRe: C# Active FTP Data Transfer Pin
eddieg767-Jun-05 12:42
eddieg767-Jun-05 12:42 
GeneralRe: C# Active FTP Data Transfer Pin
S. Senthil Kumar5-Jun-05 4:10
S. Senthil Kumar5-Jun-05 4:10 
GeneralRe: C# Active FTP Data Transfer Pin
eddieg766-Jun-05 16:55
eddieg766-Jun-05 16:55 
GeneralRe: C# Active FTP Data Transfer Pin
S. Senthil Kumar6-Jun-05 17:40
S. Senthil Kumar6-Jun-05 17:40 
GeneralHELP overriding windows message Pin
Sasuko4-Jun-05 15:13
Sasuko4-Jun-05 15:13 
GeneralRe: HELP overriding windows message Pin
Luis Alonso Ramos4-Jun-05 17:01
Luis Alonso Ramos4-Jun-05 17:01 
Generalcorrect way in c# to... Pin
rocky_pulley4-Jun-05 12:05
rocky_pulley4-Jun-05 12:05 
GeneralRe: correct way in c# to... Pin
Carsten Zeumer4-Jun-05 12:29
Carsten Zeumer4-Jun-05 12:29 
GeneralRe: correct way in c# to... Pin
S. Senthil Kumar5-Jun-05 4:14
S. Senthil Kumar5-Jun-05 4:14 
GeneralTabAlignment change messing up my buttons' mouse events Pin
Flack4-Jun-05 10:50
Flack4-Jun-05 10:50 
GeneralProblem with MySQL connection Pin
tantiboh4-Jun-05 10:01
tantiboh4-Jun-05 10:01 
GeneralRe: Problem with MySQL connection Pin
Dave Kreskowiak4-Jun-05 15:58
mveDave Kreskowiak4-Jun-05 15:58 
Generalcaputring a textbox Pin
Anonymous4-Jun-05 9:21
Anonymous4-Jun-05 9:21 
GeneralRe: caputring a textbox Pin
MoustafaS4-Jun-05 11:38
MoustafaS4-Jun-05 11:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.