hey there, i want to know how to send files via tcp connection, i am using a socket to connect to the tcplistener. i used to be able to send messages, i remember it was something to do with text.encoding, thats not real big, i can find that on a tutorial again, but i would really appreciate if someone showed me how to send a file. now im not connected asyncronylously. i just use the simple .connect method for now. so idk if i wanna use the beginsend, and then beginreceive, because when i just use socket.sendfile that could work, but how would i receive it on the server's side. would i have to read the network stream, and put it together? plz help... i do have some code, im willing to show if anyone suggests im just getting people to do my "homework". ok, plz help, thanks in advance =)
5 1157
First, know that this will most likely (99%) not answer your question, but will instead give you a headstart. If you were transferring a big file, you would probably have to send bits at a time. First, you convert that "big file" into a byte array. You cut off a bit of the byte array to send. For that bit you just cut off, tag it so the other side knows that there is more to come (there is a lot more byte arrays to send). To tag it, add a few bytes with a special code like "UNFINISHED". When the other side reads the byte array and sees "UNFINISHED", it stores it into a bigger byte array storage and waits for more.
Correct me if i'm wrong.
1) Connect socket
2) Open file
3) Send file bytes on socket
4) Repeat step 3 until all bytes are sent
5) Close file
6) Close socket (or whatever you feel like for your protocol)
1) Connect socket
2) Open file
3) Send file bytes on socket
4) Repeat step 3 until all bytes are sent
5) Close file
6) Close socket (or whatever you feel like for your protocol)
how would i come across doing this ? like for step 3 use the socket.sendfile? and how to read it? like i'd rather do a network stream from just the tcpclient.getstream and write to that.
How you do it is up to you.
You just send bytes accross a socket. So open your file up, read in the bytes and send the bytes over the socket.
How you control the talking back and forth is all up to you.
How you do it is up to you.
You just send bytes accross a socket. So open your file up, read in the bytes and send the bytes over the socket.
How you control the talking back and forth is all up to you.
i know that but i tried sending a simple small jpeg over the networkstream and i'd get most of it, but it would should like a gray(blank) spot where i guess it didnt receive all of the data, idk i guess i'll work on it, and i dont remember that code either, i'll just google some more
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sven Templin |
last post by:
Hello all,
our configuration is as following described:
- OS: Windows 2000
- Apache server 1.3
- Php 3.8
- MS outlook client 2000
_and_ no SMTP server available in the whole intranet.
|
by: Nis Sarup |
last post by:
A customer of mine wants to make a newsletter for their website. The
newsletter should be HTML with images and sent to a database of her
subscribers.
They would like a script where they can easily...
|
by: Dragos Marian Barbu |
last post by:
Recently I tried to develop a function to help me sending e-mail messages
with more than one attachment. Everything is working OK when I am sebding
messages with one attachment, but when I try to...
|
by: Buddy Ackerman |
last post by:
I'm sending file to the client (see sample code below) but when I send a large file the user gets a document contains no
data message.
response.contenttype = "application/x-unknown"
myheader =...
|
by: Buddy Ackerman |
last post by:
I'm sending file to the client (see sample code below) but when I send a large file the user gets a document contains no
data message.
response.contenttype = "application/x-unknown"
myheader =...
|
by: Jeff |
last post by:
Hey
ASP.NET 2.0
This the ObjectDataSource in my UserControl,
<asp:ObjectDataSource ID="odsMessage" runat="server"
SelectMethod="ExecuteMessage"
TypeName="AH.MyNetwork.BLL.Network.Message">...
|
by: Robert Dufour |
last post by:
Dim message As New MailMessage("mymail@mydomain.com", "mymail@mydomain.com",
"Test", "Test")
Dim emailClient As New SmtpClient("localhost")
emailClient.Send(message)
The IIS server is...
|
by: nautonnier |
last post by:
Hello,
I have a C# app that spawns several processes each containing a console
app written by another developer in C++. The console app was written
first to be just like a console app: it...
|
by: robbiesmith79 |
last post by:
Just so this is out there on the web, I battled the past 24 hours
about this. Background info... I developed a ecommerce website in PHP
4 on a shared linux hosting plan from GoDaddy and had the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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,...
| |