473,789 Members | 2,893 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 2360
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
18136
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
11729
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
28655
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
6879
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
4044
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
4314
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
2260
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
7186
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
9511
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,...
0
10408
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
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
5417
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...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
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
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.