473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to tell when the socket has received all the data?

I have created 2 vb.net applications in VS 2002, a server and a client using
the .net.sockets namespace. I can connect and receive data fine but the
client cannot tell when it has recived all the data from the server and close
the file.

I'm sending multiple request for data and I do not want to close the
connecting everytime the entire file has been sent from the server and then
reconnect. I'm sending binary data, is there anyway to tell the client the
size of the file the server is sending?
Nov 22 '05 #1
3 2340
This is a useful article that may help:
http://www.yoda.arachsys.com/csharp/readbinary.html

In addition, it you are in control of both sides, you could add a size
indicator at the start of the data you send.

HTH
Dan

"DJTN" wrote:
I have created 2 vb.net applications in VS 2002, a server and a client using
the .net.sockets namespace. I can connect and receive data fine but the
client cannot tell when it has recived all the data from the server and close
the file.

I'm sending multiple request for data and I do not want to close the
connecting everytime the entire file has been sent from the server and then
reconnect. I'm sending binary data, is there anyway to tell the client the
size of the file the server is sending?

Nov 22 '05 #2
So add a piece of binary data at the beginning of the data to send with the
file size?

Does anyone know of a good book for sockets programming in VB.net?

DJTN

"Dan Kelley" wrote:
This is a useful article that may help:
http://www.yoda.arachsys.com/csharp/readbinary.html

In addition, it you are in control of both sides, you could add a size
indicator at the start of the data you send.

HTH
Dan

"DJTN" wrote:
I have created 2 vb.net applications in VS 2002, a server and a client using
the .net.sockets namespace. I can connect and receive data fine but the
client cannot tell when it has recived all the data from the server and close
the file.

I'm sending multiple request for data and I do not want to close the
connecting everytime the entire file has been sent from the server and then
reconnect. I'm sending binary data, is there anyway to tell the client the
size of the file the server is sending?

Nov 22 '05 #3
Ok, I've figured this out. Like he said, I added the file size of the file
I'm sending to the front of the binary data being sent. I then strip it out
on the other side and write the rest of the data to a stream until the stream
has reached the size of the file. Works well but you have to remember to set
your buffer sizes correctly when sending and receiving the file so you only
write the data and no extra.

DJTN

"DJTN" wrote:
I have created 2 vb.net applications in VS 2002, a server and a client using
the .net.sockets namespace. I can connect and receive data fine but the
client cannot tell when it has recived all the data from the server and close
the file.

I'm sending multiple request for data and I do not want to close the
connecting everytime the entire file has been sent from the server and then
reconnect. I'm sending binary data, is there anyway to tell the client the
size of the file the server is sending?

Nov 22 '05 #4

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

Similar topics

4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
5
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...
3
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
22
by: semedao | last post by:
Hi , I am using asyc sockets p2p connection between 2 clients. when I debug step by step the both sides , i'ts work ok. when I run it , in somepoint (same location in the code) when I want to...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: selvialagar | last post by:
i did a program in vc++.net for ICMP communication using sockets.But when i execute it i received a very slow response...is there any configuration to be made on the server..or any other thing?.. i...
2
by: Nick Toop | last post by:
Hi, I have a Java application which runs a server socket on a PC. Various sensors (using microprocessors) can call it up and each gets its own thread running the socket connection. The...
1
by: keksy | last post by:
Hi every1, I am writing a small client/server application and in it I want to send an image asynchronous from the client to the server through a TCP socket. I found an example code on the MSDN...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
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...
0
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...
0
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,...

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.