473,320 Members | 1,978 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,320 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 2336
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.