M
martins
I hope somebody is still reading this..
I have a similar problem and i'm not sure what to do. Let me start off
by saying that this is my first dive into the world of sockets.
I got some free c sharp code for a simple ftpclient.
I've been playing around with it some, trying to write a function to
return the size of a given directory on the ftp server. I think the
issue i ran into is similar to what's been discussed here but not
exactly.
In my scenario i use the straight Receive to get the data from the ftp
server and here's what i noticed. When i run the code with some
console.writeline's or step through it in a debugger it runs just
fine.
As soon as i remove the console.writeline's it fails - the size of data
received is not what its supposed be. Here is the code that executes
when this happens:
socket is created like this:
socket = new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
ep = new IPEndPoint(Dns.Resolve(ipAddress).AddressList[0], port);
socket.Connect(ep);
and then used like this:
DateTime timeout = DateTime.Now.AddSeconds(this.timeoutSeconds);
while( timeout > DateTime.Now )
{
int bytes = cSocket.Receive(buffer, buffer.Length, 0);
//if i put some Console.Writeline here it will work
otherwise it fails.
this.message += ASCII.GetString(buffer, 0, bytes);
if ( bytes < this.buffer.Length) break;
}
I'm assuming i'm experiencing the same problem ie the peer socket
closing before it's read
Please advise me on how to resolve this.
I have a similar problem and i'm not sure what to do. Let me start off
by saying that this is my first dive into the world of sockets.
I got some free c sharp code for a simple ftpclient.
I've been playing around with it some, trying to write a function to
return the size of a given directory on the ftp server. I think the
issue i ran into is similar to what's been discussed here but not
exactly.
In my scenario i use the straight Receive to get the data from the ftp
server and here's what i noticed. When i run the code with some
console.writeline's or step through it in a debugger it runs just
fine.
As soon as i remove the console.writeline's it fails - the size of data
received is not what its supposed be. Here is the code that executes
when this happens:
socket is created like this:
socket = new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
ep = new IPEndPoint(Dns.Resolve(ipAddress).AddressList[0], port);
socket.Connect(ep);
and then used like this:
DateTime timeout = DateTime.Now.AddSeconds(this.timeoutSeconds);
while( timeout > DateTime.Now )
{
int bytes = cSocket.Receive(buffer, buffer.Length, 0);
//if i put some Console.Writeline here it will work
otherwise it fails.
this.message += ASCII.GetString(buffer, 0, bytes);
if ( bytes < this.buffer.Length) break;
}
I'm assuming i'm experiencing the same problem ie the peer socket
closing before it's read
Please advise me on how to resolve this.