473,803 Members | 3,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2361
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
18139
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 as I find appropriate. I am using the socket asynchronously by calling the BeingSend and BeginReceive calls. I would like to be able to call shutdown and close asynchronously if possible.
5
11732
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 1024 with all values set to Null arrive. Other than examine a block of 1024 to see if the entire block is null, is there any other way to determine if , say a chat message "Hi Charlie" has been received completely?
3
28656
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 slowly, about 4 seconds between send and receive. In our production environment with hundreds of transactions it was truly costly. a while ago i changed de TcpClient object. Now i am using a Socket (System.Net.Sockets.Socket) object and it...
2
6880
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 there is a problem with the connection. I need to know which client has sent the incoming data as each client has its own buffer on my "server" app. I am using the standard asynch socket code from MSDN to listen for connections and they...
0
4757
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 the client application establish a connection, and send data, which appears in plain, de-crypted text on the server - this works.
22
4046
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 receive 5 bytes buffer , I call the BeginReceive and then wait on AsyncWaitHandle.WaitOne() but it is signald imidiatly , and the next call to EndReceive return zero bytes length , also the buffer is empty. here is the code: public static byte...
3
4318
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 receiver is running within Process1. If I move the receiver into Process2 then its fast. Please can someone explain.
0
2261
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 don't know the reason for slow response...i included the code for this...plz solve my problem... // pingnew.h #pragma once using namespace System; using namespace System::IO; using namespace System::Text; using namespace System::Net;
2
4260
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 sensors send in data at random times. This all works OK. Sometimes one of the sensors fails or goes off-line. How can I tell from the server end? If they fail I would like to close the link down.
1
7199
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 site, which is actually for sending strings. I tried to adapt this code so that the client sends an image instead of a string. However, there is something wrong on the server side (i guess)... The server starts listening, the client starts sending...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10289
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
10068
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...
1
7600
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
6840
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
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
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.