Hi all
I have a little FTP proggie. It works, on windows xp, but it doesnt work
properly on windows 2000. The first problem i have, is when retrieving a
list of files.
int bytes = cSocket.Receive(buffer, buffer.Length, 0);
this.message += ASCII.GetString(buffer, 0, bytes);
bytes is returned as size 18, my buffer.Length is set at 512, but i only get
18 back. i know for a fact that there is more since it works on my XP
machines. the above piece of code is in a while loop, keeps concatenating
the results to this.message.
so on the windows 2000 platforms i only get back the first file, whereas
with xp i get back the entire list. files are separated by "\r\n".
that is my first error.
the next error is when the cSocket.Receive just hangs. I think this is
because it is blocking itself until there is data to read. but i know there
is data to read, because it works on my XP machines. the programs "comes
back" after 10 mins, which is the connection idle timeout set on the FTP
server.
is there a component i need to install on the 2000 machines?
another peculiar note: I have tested it on four windows 2000 boxes. Two of
the four boxes "hang" for the 10min, where the other two of the four boxes
repond after the first few seconds. although they dont respond in the
desired way. but ALL four windows 2000 boxes only read back the first file.
windows xp works perfectly.
any suggestions are most welcome!
Thanks
Jason 8 8990
Jason <c_*******@mighty.co.za> wrote: I have a little FTP proggie. It works, on windows xp, but it doesnt work properly on windows 2000. The first problem i have, is when retrieving a list of files. int bytes = cSocket.Receive(buffer, buffer.Length, 0);
this.message += ASCII.GetString(buffer, 0, bytes);
bytes is returned as size 18, my buffer.Length is set at 512, but i only get 18 back. i know for a fact that there is more since it works on my XP machines. the above piece of code is in a while loop, keeps concatenating the results to this.message.
Right. I don't see why that's a problem. Sockets don't guarantee to
return everything in one lump - just loop until you've got everything.
(Oh, and use a StringBuilder instead of string concatenation.)
so on the windows 2000 platforms i only get back the first file, whereas with xp i get back the entire list. files are separated by "\r\n".
that is my first error.
the next error is when the cSocket.Receive just hangs. I think this is because it is blocking itself until there is data to read. but i know there is data to read, because it works on my XP machines.
I suggest you use a network analyser to confirm that, rather than just
XP machines. Perhaps the server is returning different information to
the 2000 boxes?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
I have tried looping
while (cSocket.Available != 0) {
}
yeh, stringbuilder better, thanks. just need to get this working first hehe
so what would you do? i am very new at sockets. for example how would i
check if i have everything or not?
Thanks again
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Jason <c_*******@mighty.co.za> wrote: I have a little FTP proggie. It works, on windows xp, but it doesnt work properly on windows 2000. The first problem i have, is when retrieving a list of files. int bytes = cSocket.Receive(buffer, buffer.Length, 0);
this.message += ASCII.GetString(buffer, 0, bytes);
bytes is returned as size 18, my buffer.Length is set at 512, but i only
get 18 back. i know for a fact that there is more since it works on my XP machines. the above piece of code is in a while loop, keeps
concatenating the results to this.message.
Right. I don't see why that's a problem. Sockets don't guarantee to return everything in one lump - just loop until you've got everything. (Oh, and use a StringBuilder instead of string concatenation.)
so on the windows 2000 platforms i only get back the first file, whereas with xp i get back the entire list. files are separated by "\r\n".
that is my first error.
the next error is when the cSocket.Receive just hangs. I think this is because it is blocking itself until there is data to read. but i know
there is data to read, because it works on my XP machines.
I suggest you use a network analyser to confirm that, rather than just XP machines. Perhaps the server is returning different information to the 2000 boxes?
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Jason <c_*******@mighty.co.za> wrote: I have tried looping
while (cSocket.Available != 0) { }
I wouldn't do that - I'd just let the socket block. Just loop around
until you know that you've got everything.
yeh, stringbuilder better, thanks. just need to get this working first hehe
so what would you do? i am very new at sockets. for example how would i check if i have everything or not?
The protocol should include appropriate data. There's no concept in a
network stream of "the end" until the connection is closed.
I can't remember exactly how FTP works, but I'm sure there'll be
something you can use to detect when you've finished receiving the
current file (or list of files, or whatever).
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
thanks!
i think i have got something that may work
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Jason <c_*******@mighty.co.za> wrote: I have tried looping
while (cSocket.Available != 0) { }
I wouldn't do that - I'd just let the socket block. Just loop around until you know that you've got everything.
yeh, stringbuilder better, thanks. just need to get this working first
hehe so what would you do? i am very new at sockets. for example how would i check if i have everything or not?
The protocol should include appropriate data. There's no concept in a network stream of "the end" until the connection is closed.
I can't remember exactly how FTP works, but I'm sure there'll be something you can use to detect when you've finished receiving the current file (or list of files, or whatever).
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
RFC 959 indicates that the end of line is indicated with a CRLF
sequence.
You can find RFC 959 at: http://www.w3.org/Protocols/rfc959/
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Jason <c_*******@mighty.co.za> wrote: I have tried looping
while (cSocket.Available != 0) { }
I wouldn't do that - I'd just let the socket block. Just loop around until you know that you've got everything.
yeh, stringbuilder better, thanks. just need to get this working first
hehe so what would you do? i am very new at sockets. for example how would i check if i have everything or not?
The protocol should include appropriate data. There's no concept in a network stream of "the end" until the connection is closed.
I can't remember exactly how FTP works, but I'm sure there'll be something you can use to detect when you've finished receiving the current file (or list of files, or whatever).
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
sigh, i thought this would work (from MSDN)
// Receive the host home page content and loop until all the data is
received.
Int32 bytes = s.Receive(RecvBytes, RecvBytes.Length, 0);
strRetPage = "Default HTML page on " + server + ":\r\n";
strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
while (bytes > 0)
{
bytes = s.Receive(RecvBytes, RecvBytes.Length, 0);
strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
}
but i also get "blocked"
yeh CRLF is "\r\n" which is what separates my file names...
Thanks
Jason
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl... RFC 959 indicates that the end of line is indicated with a CRLF sequence.
You can find RFC 959 at:
http://www.w3.org/Protocols/rfc959/
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message news:MP************************@msnews.microsoft.c om... Jason <c_*******@mighty.co.za> wrote: I have tried looping
while (cSocket.Available != 0) { }
I wouldn't do that - I'd just let the socket block. Just loop around until you know that you've got everything.
yeh, stringbuilder better, thanks. just need to get this working first hehe so what would you do? i am very new at sockets. for example how would
i check if i have everything or not?
The protocol should include appropriate data. There's no concept in a network stream of "the end" until the connection is closed.
I can't remember exactly how FTP works, but I'm sure there'll be something you can use to detect when you've finished receiving the current file (or list of files, or whatever).
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Jason <c_*******@mighty.co.za> wrote: sigh, i thought this would work (from MSDN)
// Receive the host home page content and loop until all the data is received. Int32 bytes = s.Receive(RecvBytes, RecvBytes.Length, 0); strRetPage = "Default HTML page on " + server + ":\r\n"; strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
while (bytes > 0) { bytes = s.Receive(RecvBytes, RecvBytes.Length, 0); strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes); }
but i also get "blocked"
yeh CRLF is "\r\n" which is what separates my file names...
Yes, you would get blocked - because the server hasn't been told to
close the connection at the end of the request, presumably.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
> while (bytes > 0) { bytes = s.Receive(RecvBytes, RecvBytes.Length, 0); strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes); }
but i also get "blocked"
Yeh. This blocks as you would expect and need. You need it to block as you
never know when the next packet you get. You need to know when you have
read all the data. This would be a determined based on a header that is
passed with a length or after a certain character combination (not sure
about how ftp does this.) I would look a bit more at the rfc, it should be
able to infer when you know you have all the data. The other route is to
use Indy .Net which has an FTP class in it and works well and its free.
Cheers!
--
William Stacey, MVP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DreJoh |
last post by:
I've read many articles on the subject and the majority of them give the same
solution that's in article 821625 on the MSDN website. I'm using the
following code and when a the client disconnects...
|
by: Robert A. van Ginkel |
last post by:
Hello Fellow Developer,
I use the System.Net.Sockets to send/receive data (no
tcpclient/tcplistener), I made a receivethread in my wrapper, the
receivethread loops/sleeps while waiting for data...
|
by: roger beniot |
last post by:
I have a program that launches multiple threads with a ThreadStart
method like the following (using System.Net.Sockets.Socket for UDP
packet transfers to a server):
ThreadStart pseudo code:
...
|
by: Qingdong Z. |
last post by:
I have an asynchronous Server Socket to push data to client (Socket.BeginSend) when data is available, Meanwhile, the client socket use Synchronous Client Socket to receive the data. I have two...
|
by: mscirri |
last post by:
The code below is what I am using to asynchronously get data from a
PocketPC device. The data comes in fine in blocks of 1024 bytes but
even when I send no data from the PocketPC constant blocks of...
| |
by: Droopy |
last post by:
Hi,
I try to implement a reusable socket class to send and receive data.
It seems to work but I have 2 problems :
1) I rely on Socket.Available to detect that the connection is closed (no...
|
by: Nuno Magalhaes |
last post by:
I've got a simple problem I guess. How do I know when a connection is
terminated without losing any data?
I do something like the code below, but sometimes between
socket.Receive and socket.Send...
|
by: djc |
last post by:
I read a network programming book (based on framework 1.1) which indicated
that you should 'never' use the RecieveTimeout or the SendTimeout 'socket
options' on TCP sockets or you may loose data. I...
|
by: Rene Sørensen |
last post by:
I'm using .NET 2.0 VS 2005
I'm creating a function that dos something similar to the.
SmoApplication.EnumAvailableSqlServers() function. But for som resone
I get an error or do i?. The problem...
|
by: =?Utf-8?B?UmFqbmk=?= |
last post by:
Dear William Stacey,
I have written a server code using the Windows Socket API's. Wherein I have
created the socket and bound it to a particular IP address and port number.
Later I have made the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |