473,748 Members | 8,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file transfer with sockets

I have googled to no avail on getting specifically what I'm looking for. I
have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server, server/client.
Both server and client are my program so I'm not looking for how to
implement an FTP client, or how to download a file from a web server via
http etc... Protocol between my client/server is a simple command based
structure and I intended on it going something like this in english:

this example is client to server scenario but I'll implement on both ends..
so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files size
(or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done

I've given these steps here to be clear and specific on the part I'm trying
to learn how to do. I can do all steps here fine except step 4, the actual
send/receive of the file. Help on that would be greatly appreciated.

I'm not even sure if those specific steps will stay like that, I only used
them to narrow down the area of my question. Further, I'm looking to do this
with the sockets directly, using socket.send and socket.receive, (or their
async methods), as I've read elseware that is the most effecient way, as
opposed to using a networkstream object. Aside from help on the specific
task I'm trying to learn, any comments on which technique is a good choice
are also welcome (socket.send etc... networkstream object.. and I honestly
just saw a 'socket.sendfil e' method in VS help before finishing drafting
this post... I'm posting anyway since I learn a lot from this forum, and
even if one of the higher level classes is a better choice, I want to learn
the socket way first.)


May 16 '07 #1
10 10623
David,

You don't have to use the NetworkStream object, you can use a Socket
object just fine. Once you have the file on the server side, you can just
read the bytes from the file in chunks, and then pass them to the Send
method, sending the bytes over the stream. Of course, your client has to
read them, and it has to read only the number of bytes that you are going to
send (which it already knows because you sent the length already).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"David" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>I have googled to no avail on getting specifically what I'm looking for. I
have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server, server/client.
Both server and client are my program so I'm not looking for how to
implement an FTP client, or how to download a file from a web server via
http etc... Protocol between my client/server is a simple command based
structure and I intended on it going something like this in english:

this example is client to server scenario but I'll implement on both
ends.. so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files size
(or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done

I've given these steps here to be clear and specific on the part I'm
trying to learn how to do. I can do all steps here fine except step 4, the
actual send/receive of the file. Help on that would be greatly
appreciated.

I'm not even sure if those specific steps will stay like that, I only used
them to narrow down the area of my question. Further, I'm looking to do
this with the sockets directly, using socket.send and socket.receive, (or
their async methods), as I've read elseware that is the most effecient
way, as opposed to using a networkstream object. Aside from help on the
specific task I'm trying to learn, any comments on which technique is a
good choice are also welcome (socket.send etc... networkstream object..
and I honestly just saw a 'socket.sendfil e' method in VS help before
finishing drafting this post... I'm posting anyway since I learn a lot
from this forum, and even if one of the higher level classes is a better
choice, I want to learn the socket way first.)


May 16 '07 #2
Hi,

"David" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
this example is client to server scenario but I'll implement on both
ends.. so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files size
(or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done
Sounds like a workable protocol to me :)
I'm not even sure if those specific steps will stay like that, I only used
them to narrow down the area of my question. Further, I'm looking to do
this with the sockets directly, using socket.send and socket.receive, (or
their async methods)
Start with the sync.ed method first, IMO async should only be used in
interactive applications. In the same way you can have a sync server and an
async client.
>, as I've read elseware that is the most effecient way, as opposed to using
a networkstream object. Aside from help on the specific task I'm trying to
learn, any comments on which technique is a good choice are also welcome
(socket.send etc... networkstream object..
Just use Socket Send/Receive, it should be trivial to implement. just a
simple loop whiel you have bytes to read (you already knowthe file size).
May 16 '07 #3
Hi Nicholas,
"Once you have the file on the server side, you can just
read the bytes from the file in chunks, and then pass them to the Send
method, sending the bytes over the stream. Of course, your client has to
read them, and it has to read only the number of bytes that you are going to
send (which it already knows because you sent the length already)."

I don't know what that would actually look like on sending and receiving
end? However I get the concept.
I'm embarrassed to say but I really haven't used .net's streaming IO model
yet... I used vb4 a long time ago, my programming activities now are mostly
scripting for automation related to network administration. I'm just now
really trying to get into c#/.net/network programming. I get that all .net
IO uses streams, and that I would use a stream (or fileStream?) to read the
file from disk on server, assuming reading it into a byte buffer, then using
the socket to send that byte buffer. But how do I, for example, control and
keep track of the 'chunks', you mentioned? would it be one call to
socket.send after accumulating all the file chunks or a loop resulting in
multiple calls to socket.send? I assume a loop is more likely so it would
work on small and large files... unfortunately I am still at the beginning
learning stages of this and lack some crucial fundamentals. But I can pick
it up real quick because of past programming experience and some admin
scripting.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
David,

You don't have to use the NetworkStream object, you can use a Socket
object just fine. Once you have the file on the server side, you can just
read the bytes from the file in chunks, and then pass them to the Send
method, sending the bytes over the stream. Of course, your client has to
read them, and it has to read only the number of bytes that you are going
to send (which it already knows because you sent the length already).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"David" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>>I have googled to no avail on getting specifically what I'm looking for. I
have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server, server/client.
Both server and client are my program so I'm not looking for how to
implement an FTP client, or how to download a file from a web server via
http etc... Protocol between my client/server is a simple command based
structure and I intended on it going something like this in english:

this example is client to server scenario but I'll implement on both
ends.. so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files size
(or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done

I've given these steps here to be clear and specific on the part I'm
trying to learn how to do. I can do all steps here fine except step 4,
the actual send/receive of the file. Help on that would be greatly
appreciated.

I'm not even sure if those specific steps will stay like that, I only
used them to narrow down the area of my question. Further, I'm looking to
do this with the sockets directly, using socket.send and socket.receive,
(or their async methods), as I've read elseware that is the most
effecient way, as opposed to using a networkstream object. Aside from
help on the specific task I'm trying to learn, any comments on which
technique is a good choice are also welcome (socket.send etc...
networkstrea m object.. and I honestly just saw a 'socket.sendfil e' method
in VS help before finishing drafting this post... I'm posting anyway
since I learn a lot from this forum, and even if one of the higher level
classes is a better choice, I want to learn the socket way first.)



May 16 '07 #4
David,

Yes, you would use a filestream. You would make calls to Read on the
filestream instance, reading say, 1KB of bytes (or any other number you feel
is appropriate depending on the size of the files you will typically send)
at a time, and then passing the byte array that you read the contents into
to the Send method on the socket.

You could load the entire contents of the file into one big byte array,
but that wouldn't be too efficient, and would gobble up memory for large
files (hence the reading in chunks).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"David" <no****@nospam. comwrote in message
news:eI******** ******@TK2MSFTN GP05.phx.gbl...
Hi Nicholas,
"Once you have the file on the server side, you can just
read the bytes from the file in chunks, and then pass them to the Send
method, sending the bytes over the stream. Of course, your client has to
read them, and it has to read only the number of bytes that you are going
to
send (which it already knows because you sent the length already)."

I don't know what that would actually look like on sending and receiving
end? However I get the concept.
I'm embarrassed to say but I really haven't used .net's streaming IO model
yet... I used vb4 a long time ago, my programming activities now are
mostly scripting for automation related to network administration. I'm
just now really trying to get into c#/.net/network programming. I get that
all .net IO uses streams, and that I would use a stream (or fileStream?)
to read the file from disk on server, assuming reading it into a byte
buffer, then using the socket to send that byte buffer. But how do I, for
example, control and keep track of the 'chunks', you mentioned? would it
be one call to socket.send after accumulating all the file chunks or a
loop resulting in multiple calls to socket.send? I assume a loop is more
likely so it would work on small and large files... unfortunately I am
still at the beginning learning stages of this and lack some crucial
fundamentals. But I can pick it up real quick because of past programming
experience and some admin scripting.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote
in message news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>David,

You don't have to use the NetworkStream object, you can use a Socket
object just fine. Once you have the file on the server side, you can
just read the bytes from the file in chunks, and then pass them to the
Send method, sending the bytes over the stream. Of course, your client
has to read them, and it has to read only the number of bytes that you
are going to send (which it already knows because you sent the length
already).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"David" <no****@nospam. comwrote in message
news:%2******* *********@TK2MS FTNGP03.phx.gbl ...
>>>I have googled to no avail on getting specifically what I'm looking for.
I have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server,
server/client. Both server and client are my program so I'm not looking
for how to implement an FTP client, or how to download a file from a web
server via http etc... Protocol between my client/server is a simple
command based structure and I intended on it going something like this in
english:

this example is client to server scenario but I'll implement on both
ends.. so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files
size (or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done

I've given these steps here to be clear and specific on the part I'm
trying to learn how to do. I can do all steps here fine except step 4,
the actual send/receive of the file. Help on that would be greatly
appreciated .

I'm not even sure if those specific steps will stay like that, I only
used them to narrow down the area of my question. Further, I'm looking
to do this with the sockets directly, using socket.send and
socket.receiv e, (or their async methods), as I've read elseware that is
the most effecient way, as opposed to using a networkstream object.
Aside from help on the specific task I'm trying to learn, any comments
on which technique is a good choice are also welcome (socket.send etc...
networkstre am object.. and I honestly just saw a 'socket.sendfil e'
method in VS help before finishing drafting this post... I'm posting
anyway since I learn a lot from this forum, and even if one of the
higher level classes is a better choice, I want to learn the socket way
first.)




May 16 '07 #5
On Wed, 16 May 2007 09:42:23 -0700, Nicholas Paldino [.NET/C# MVP]
<mv*@spam.guard .caspershouse.c omwrote:
[...]
You could load the entire contents of the file into one big byte
array, but that wouldn't be too efficient, and would gobble up memory
for large files (hence the reading in chunks).
And of course would not even work for files too large to fit in the
process's address space. :)
May 16 '07 #6
I've been reading up on streams and file I/O to make this come together. Two
questions:

1) should I just send each file chunk consecutively or wait for a
confirmation from client for each chunk before sending the next?

2) my current structure is a simple command/response setup. I send command
to server, server interprets command, executes it, then simply returns
results of the command... I did this using asynch calls for both client and
server. Is it ok to use the synch calls now from within my asynch callbacks
for the file transfer? a read a book that said something about not mixing
the asynch and synch calls? starving the threadpool? I'm in over my head but
making progress :)

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
David,

Yes, you would use a filestream. You would make calls to Read on the
filestream instance, reading say, 1KB of bytes (or any other number you
feel is appropriate depending on the size of the files you will typically
send) at a time, and then passing the byte array that you read the
contents into to the Send method on the socket.

You could load the entire contents of the file into one big byte array,
but that wouldn't be too efficient, and would gobble up memory for large
files (hence the reading in chunks).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"David" <no****@nospam. comwrote in message
news:eI******** ******@TK2MSFTN GP05.phx.gbl...
>Hi Nicholas,
"Once you have the file on the server side, you can just
read the bytes from the file in chunks, and then pass them to the Send
method, sending the bytes over the stream. Of course, your client has to
read them, and it has to read only the number of bytes that you are going
to
send (which it already knows because you sent the length already)."

I don't know what that would actually look like on sending and receiving
end? However I get the concept.
I'm embarrassed to say but I really haven't used .net's streaming IO
model yet... I used vb4 a long time ago, my programming activities now
are mostly scripting for automation related to network administration.
I'm just now really trying to get into c#/.net/network programming. I get
that all .net IO uses streams, and that I would use a stream (or
fileStream?) to read the file from disk on server, assuming reading it
into a byte buffer, then using the socket to send that byte buffer. But
how do I, for example, control and keep track of the 'chunks', you
mentioned? would it be one call to socket.send after accumulating all the
file chunks or a loop resulting in multiple calls to socket.send? I
assume a loop is more likely so it would work on small and large files...
unfortunatel y I am still at the beginning learning stages of this and
lack some crucial fundamentals. But I can pick it up real quick because
of past programming experience and some admin scripting.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote
in message news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>>David,

You don't have to use the NetworkStream object, you can use a Socket
object just fine. Once you have the file on the server side, you can
just read the bytes from the file in chunks, and then pass them to the
Send method, sending the bytes over the stream. Of course, your client
has to read them, and it has to read only the number of bytes that you
are going to send (which it already knows because you sent the length
already).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"David" <no****@nospam. comwrote in message
news:%2****** **********@TK2M SFTNGP03.phx.gb l...
I have googled to no avail on getting specifically what I'm looking for.
I have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow
for using a tcp socket to transfer files between client/server,
server/client. Both server and client are my program so I'm not looking
for how to implement an FTP client, or how to download a file from a web
server via http etc... Protocol between my client/server is a simple
command based structure and I intended on it going something like this
in english:

this example is client to server scenario but I'll implement on both
ends.. so client/server can be server/client etc..
1) client requests a file from server
2) server verifies file exists and sends back an 'ok' with the files
size (or message saying no file exists)
3) client receives file's size and sends the 'ok' to start the transfer
4) server sends file / client receives file
5) client sends 'ok' after receive is done

I've given these steps here to be clear and specific on the part I'm
trying to learn how to do. I can do all steps here fine except step 4,
the actual send/receive of the file. Help on that would be greatly
appreciate d.

I'm not even sure if those specific steps will stay like that, I only
used them to narrow down the area of my question. Further, I'm looking
to do this with the sockets directly, using socket.send and
socket.recei ve, (or their async methods), as I've read elseware that is
the most effecient way, as opposed to using a networkstream object.
Aside from help on the specific task I'm trying to learn, any comments
on which technique is a good choice are also welcome (socket.send
etc... networkstream object.. and I honestly just saw a
'socket.send file' method in VS help before finishing drafting this
post... I'm posting anyway since I learn a lot from this forum, and
even if one of the higher level classes is a better choice, I want to
learn the socket way first.)




May 16 '07 #7
On Wed, 16 May 2007 14:27:39 -0700, David <no****@nospam. comwrote:
1) should I just send each file chunk consecutively or wait for a
confirmation from client for each chunk before sending the next?
You should just send it. In fact, you should not really need to get
confirmation for any chunk of data at all. Armed with the knowledge of
how long the file being sent is, the receiver can just keep receiving data
until they've received that many bytes, and then send a single
confirmation at the very end (if desired...many file transfer
implementations don't even bother to do this, since the client can
determine for itself whether all the bytes were sent and do something
appropriate if they weren't).
2) my current structure is a simple command/response setup. I send
command
to server, server interprets command, executes it, then simply returns
results of the command... I did this using asynch calls for both client
and server. Is it ok to use the synch calls now from within my asynch
callbacks for the file transfer? a read a book that said something about
not mixing the asynch and synch calls? starving the threadpool? I'm in
over my head but making progress :)
I'm not really sure what the book you read is discussing, but I can see
how if in the callback for an asynch method, you then called some synch
method, that could cause the callback to block and thus tie up a
threadpool thread. With enough threadpool threads blocked waiting on
synchronous methods, that could indeed cause you to run out of threadpool
threads (of course, for this to happen you'd need more than one Socket
with which to create outstanding asynchronous i/o requests, and it doesn't
sound like that would happen in your case...still, it's not good design).

So, no...I don't think you should use synchronous Socket calls from within
your callback. Now, that doesn't mean you can't call *any* synchronous
calls. Even a synchronous call to read more data from your file stream so
that you can send another chunk of data should be fine. Yes, the file i/o
would be done synchronously, but relative to the network the disk i/o
should be extremely fast and shouldn't be a problem.

Pete
May 16 '07 #8
thanks Peter, sorry for the delayed response.. I was out of the office a few
days. I appreciate the help. A question has come to mind that I didn't think
about until exploring transferring files because up to this point I have
only sent small amounts of data back and forth... the asynch model requires
callbacks... below is one of the callbacks I'm using for receiving data. Its
based on an example I got from MSDN. Notice how within the callback method a
new socket.beginRec eive is initiated. The first socket.beginRec eive is
called from a different method, which obviously calls this callback method,
then within this callback method, another socket.beginRec eive is called..
and so on until all data is received. Kind of calling itself recursively.

My questions: when this happens, is a new threadpool thread taken each time
the callback is called within this iterative process? I am thinking about
this because I'm figuring out how I should handle file transfers, but also,
just trying to further my understanding in general, of socket communication
and the asynch model. I'm wondering about, in the case of large amounts of
data (like a file transfer), the possible overhead of taking a new thread
each time.. possibly hundreds of iterations transferring a large file? Below
is example of receiving end but my same questions apply to sending end as
well... is it ok to loop through these asynch calls for transferring large
amounts of data? or should I be setting up one new thread myself and using
the synchronous socket send/receive calls just for the large transfers?

private static void ReceiveCallback (IAsyncResult ar)
{
try
{
// Retrieve my state object
StateObject state = (StateObject)ar .AsyncState;

int bytesRead = state.clientSoc ket.EndReceive( ar);

if (bytesRead 0)
{
// There might be more data, so store the data received
so far.
state.sb.Append (Encoding.ASCII .GetString(stat e.buffer,
0, bytesRead));

// Get the rest of the data.
state.clientSoc ket.BeginReceiv e(state.buffer, 0,
state.bufferSiz e, 0, new AsyncCallback(R eceiveCallback) , state);
}
else
{
// All the data has arrived;
// Signal that all bytes have been received.
g_receiveDone.S et();
}
}
catch (Exception e)
{
Console.WriteLi ne(e.ToString() );
}
}
"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Wed, 16 May 2007 14:27:39 -0700, David <no****@nospam. comwrote:
>1) should I just send each file chunk consecutively or wait for a
confirmation from client for each chunk before sending the next?

You should just send it. In fact, you should not really need to get
confirmation for any chunk of data at all. Armed with the knowledge of
how long the file being sent is, the receiver can just keep receiving data
until they've received that many bytes, and then send a single
confirmation at the very end (if desired...many file transfer
implementations don't even bother to do this, since the client can
determine for itself whether all the bytes were sent and do something
appropriate if they weren't).
>2) my current structure is a simple command/response setup. I send
command
to server, server interprets command, executes it, then simply returns
results of the command... I did this using asynch calls for both client
and server. Is it ok to use the synch calls now from within my asynch
callbacks for the file transfer? a read a book that said something about
not mixing the asynch and synch calls? starving the threadpool? I'm in
over my head but making progress :)

I'm not really sure what the book you read is discussing, but I can see
how if in the callback for an asynch method, you then called some synch
method, that could cause the callback to block and thus tie up a
threadpool thread. With enough threadpool threads blocked waiting on
synchronous methods, that could indeed cause you to run out of threadpool
threads (of course, for this to happen you'd need more than one Socket
with which to create outstanding asynchronous i/o requests, and it doesn't
sound like that would happen in your case...still, it's not good design).

So, no...I don't think you should use synchronous Socket calls from within
your callback. Now, that doesn't mean you can't call *any* synchronous
calls. Even a synchronous call to read more data from your file stream so
that you can send another chunk of data should be fine. Yes, the file i/o
would be done synchronously, but relative to the network the disk i/o
should be extremely fast and shouldn't be a problem.

Pete

May 21 '07 #9
On Mon, 21 May 2007 06:38:09 -0700, David <no****@nospam. comwrote:
[...] Notice how within the callback method a
new socket.beginRec eive is initiated. The first socket.beginRec eive is
called from a different method, which obviously calls this callback
method,
then within this callback method, another socket.beginRec eive is called..
and so on until all data is received. Kind of calling itself recursively.

My questions: when this happens, is a new threadpool thread taken each
time the callback is called within this iterative process?
That's fine. It is true that when you post a new buffer for receiving (or
sending), it's possible that receive could complete causing another thread
to run, but a) as long as you don't take too much time in the current
callback, it's likely your thread will finish before, or at least have at
most one more timeslice left when, the other thread runs and b) since i/o
is so much slower than what the CPU is capable of dealing with, it's very
unlikely that you could keep enough threads busy handling i/o to actually
run out of thread-pool threads. I could see having a few threads all
active at once, but at some point you're going to run out of data, all
those threads will complete, and the pool will be idle until the next bit
of data shows up.

It's important to understand that calling BeginReceive does not assign a
thread for execution right away. It posts a buffer assigned to an i/o
completion port, and not until the i/o on that port has completed will any
thread actually be assigned to handle the completion event. In other
words, no i/o, no thread running, and if there is i/o then you DO want a
thread to run and handle the i/o as soon as you can.

The paradigm you're seeing in that sample code is the .NET variation of
using Winsock with i/o completion ports, which is the most efficient, most
scalable version of network i/o that Windows has to offer. You should be
able to confidently use the async pattern for the .NET Socket class,
following the example code, without worrying about using up your thread
pool.

Pete
May 21 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
353
by: clintonG | last post by:
That's the title of the suggestion I just left at MSDN Product Feedback Center . Please login, use that string to find the suggestion I made and vote for it to support my outrageous demands. If you login, you can read the whole story why I have gone over the edge and why something must be done about the File Transfer Manager (FTM). Briefly, I (we) are agreeing that the FTM is crippleware and needs to include the ability to report the...
11
6638
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to transfer data across.On the serve I am using Socket 2 API (recv function to read bytes)and not using ..NET. I use FileStream to open the file on the pocket pc, then associate a BinaryReader object with the stream and call ReadBytes to read all the...
3
592
by: Papanii | last post by:
Hi Guys, I am a newbie to the whole dot net framework and need a few pointers. I want to create an file transfer program (i.e form PC to PC) but i don't know where to start. Can anyone point me to the right resources? Thanx.. --Papanii
2
1620
by: Joe_Black | last post by:
Hi all, I am writing a windows forms app that I want to connect to our equipment over an ADSL connection, this equipment contains data that I wish to download. Which, in your opinions, is the best route to go to transfer this file: FTP, I have read that this can be unreliable, and needs a lot of coding to make robust. a third party component is not an option.
2
2497
by: Pramod | last post by:
Hi all, I have created a chat application, and one of it's functionality to send files to the connected user. I read the contents of the files into a Byte array and send that through sockets. Now when i send a file of 150 kb size the file seems to be corrupted at the receivers end. some part of the file is not received. Is there any restriction of size for sending files across internet using sockets?
3
11040
by: shahla.saeed | last post by:
hi, plzz check my code and let me know where the problem is lying...becuase whenever i try to tansfer the file of 573KB(mp3) it just tranfer few Kb of file(Somtimes 5.2Kb,somtimes 32Kb..every time i run the program).....but when i watch the transfering of bytes by debuging it.(RED dot on while(nfs.CanRead) )..it shows that complete bytes are transfered.(in my case i-e 573Kb)....i am unable to understand whats going wrong in my program....
5
8240
by: raghubr | last post by:
Hi all, Can any one pls guide me through..I need to transfer the file from server to client and client to server using sockets in an Asynchronous mode so this file transfer doesn't hinder the common process of connecting and of the server and client... here is the code i am trying to implement. this code snippet is for message transfer only for multiple clients. /////////////////////////////file receive method when sent from...
3
3561
by: prognoob | last post by:
I need help coding a file transfer in C#. It would be over TCP/IP using sockets... most of the solutions i have come across, they use networkstream and i have read online that there is no need to use networkstream with c# sockets... so how do I do it? also, do I need to worry about serialization/deserialization? any help would be greatly appreciated
0
1648
by: toto1980 | last post by:
Hi; I tried look for a simple way of sending a file using sockets, I found one in the old forums but I am not sure why the file when it is sent, the client side some how receive wrong contents, and when having a big file let us say 200 KB, the file transfer is not complete. Here is the code: Client side (receiver): /////////////////////////Receiving a file/////////////////////// Code: FILE *fp; char name="t.txt";
1
9321
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.