Hi There,
I have a basic TCP client and TCP server in C++. The TCP client
connects to the server, and after a setup phase starts to transmit a
file to the TCP server using multiple packets (fixed amount of bytes,
except for the last packet). This is accomplished by using a for loop
and the "int send(socket, buffer, bufferlength, 0)" function.
When I read the packets using "int recv(socket, buffer, 1500, 0)" the
number returned by the function is 1500, although the "data" packets
that I have sent each contains less bytes (1310 bytes). It seems that
with each recv() function, I get 1500 bytes from the network buffer,
and that I have lost "synchronisation" - I don't read packet for
packet, but a chunk of the network buffer. Is this the normal
operation of TCP, or did I break something along the way? (I would
hope that each recv function would return 1310, the size of the
original packet.)
Any help, suggestions and comments will be greatly appreciated
Jaco 5 5500
On 6/6/2007 3:38 PM, ja***********@gmail.com wrote:
Hi There,
I have a basic TCP client and TCP server in C++. The TCP client
connects to the server, and after a setup phase starts to transmit a
file to the TCP server using multiple packets (fixed amount of bytes,
except for the last packet). This is accomplished by using a for loop
and the "int send(socket, buffer, bufferlength, 0)" function.
When I read the packets using "int recv(socket, buffer, 1500, 0)" the
number returned by the function is 1500, although the "data" packets
that I have sent each contains less bytes (1310 bytes). It seems that
with each recv() function, I get 1500 bytes from the network buffer,
and that I have lost "synchronisation" - I don't read packet for
packet, but a chunk of the network buffer. Is this the normal
operation of TCP, or did I break something along the way? (I would
hope that each recv function would return 1310, the size of the
original packet.)
This is pretty OT in comp.lang.c++. Ask in comp.unix.programming for example.
But I tell you:
TCP is stream based. There are now record borders (you'd use UDP
for that). You have to transmit the record size in your packet
structure.
Regards,
Stefan
--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
On Jun 6, 8:38 pm, jaco.versf...@gmail.com wrote:
Hi There,
I have a basic TCP client and TCP server in C++. The TCP client
connects to the server, and after a setup phase starts to transmit a
file to the TCP server using multiple packets (fixed amount of bytes,
except for the last packet). This is accomplished by using a for loop
and the "int send(socket, buffer, bufferlength, 0)" function.
When I read the packets using "int recv(socket, buffer, 1500, 0)" the
number returned by the function is 1500, although the "data" packets
that I have sent each contains less bytes (1310 bytes). It seems that
with each recv() function, I get 1500 bytes from the network buffer,
and that I have lost "synchronisation" - I don't read packet for
packet, but a chunk of the network buffer. Is this the normal
operation of TCP, or did I break something along the way? (I would
hope that each recv function would return 1310, the size of the
original packet.)
Any help, suggestions and comments will be greatly appreciated
Jaco
This is OT here, you would probably get better answers elsewhere.
But, as far as i know, tcp read\write is streamed. The way, i would
go, is design a simple protocol on top of TCP with a field for record
lenght.
Thank you very much to all who replied
Kind Regards,
Jaco
On Jun 6, 6:38 am, jaco.versf...@gmail.com wrote:
I have a basic TCP client and TCP server in C++. The TCP client
connects to the server, and after a setup phase starts to transmit a
file to the TCP server using multiple packets (fixed amount of bytes,
except for the last packet). This is accomplished by using a for loop
and the "int send(socket, buffer, bufferlength, 0)" function.
Your bad terminology is going to cause you no end of pain. You are
using the term "packets" when you mean "records".
When I read the packets using "int recv(socket, buffer, 1500, 0)" the
number returned by the function is 1500, although the "data" packets
that I have sent each contains less bytes (1310 bytes).
You are probably sending 1,310 byte records in 1,500 byte packets (or,
more precisely, packets that hold up to 1,500 bytes of application
data).
It seems that
with each recv() function, I get 1500 bytes from the network buffer,
and that I have lost "synchronisation" - I don't read packet for
packet, but a chunk of the network buffer. Is this the normal
operation of TCP, or did I break something along the way?
If you call 'recv' fast enough, and no packets are lost, you *will*
receive packets. However, packets are not records.
(I would
hope that each recv function would return 1310, the size of the
original packet.)
Except that wasn't the size of the original packet, that was the size
of the original record.
Any help, suggestions and comments will be greatly appreciated
Don't call a record a packet. Sloppy terminology is your main problem.
You are sending records and receiving data as it becomes available
(which is going to be in chunks of packets).
DS
On 8 Jun, 04:58, David Schwartz <dav...@webmaster.comwrote:
On Jun 6, 6:38 am, jaco.versf...@gmail.com wrote:
I have a basic TCP client and TCP server in C++. The TCP client
connects to the server, and after a setup phase starts to transmit a
file to the TCP server using multiple packets (fixed amount of bytes,
except for the last packet). This is accomplished by using a for loop
and the "int send(socket, buffer, bufferlength, 0)" function.
Your bad terminology is going to cause you no end of pain. You are
using the term "packets" when you mean "records".
or go the whole hog and call 'em PDU's
:-)
<snip>
--
Nick Keighley This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kristian Nybo |
last post by:
Hi,
I'm writing a simple image file exporter as part of a school project. To
implement my image format of choice I need to work with big-endian
bytes, where 'byte' of course means '8 bits', not...
|
by: Phillip Rhodes |
last post by:
Hi all, I have a question I hope someone can help me with:
I'm doing some communication over a socket, and have need to send
and receive values of type double. I'm doing everything in terms
of...
|
by: Einar |
last post by:
Hi,
I wonder if there is a nice bit twiddling hack to compare a large
number of variables?
If you first store them in an array, you can do:
for (i = 0; i < n; i++) {
if (array != value) {...
|
by: Dave |
last post by:
I Have XP PRO and have a FA311 NIC working fine showing network traffic in bytes. i got a new board with onboard LAN, and it displays the traffic in packets, i have installed the newest drivers but...
|
by: David |
last post by:
I note that you can null teminate a string by adding controlchar.null.
Is there a way of adding a null to a Buffer of Bytes and converting it to a
string.
I have packets coming in from a...
| |
by: newbie |
last post by:
Hi all,
http://www.aswin.be/nictransfer.JPG
How can I get these numbers with VB.NET ?
I thought somewhere in WMI but I can't find them.
Thank you,
Aswin
|
by: darthghandi |
last post by:
I am trying to create a server application using asynchronous
sockets. I run into a problem when I try to connect to my server
using a non-.net program. I can establish the connection, and send...
|
by: Uma - Chellasoft |
last post by:
Hai,
I am working with UDP sockets in VB.Net. I am receiving UDP packets
specified for a particular port from entire network. For restriction of
packets from a single host, I am defining an...
|
by: Sam T |
last post by:
Thanks for at least reading this. Quick overview: I am new to object oriented programming (go FORTRAN) and have jumped into developing a C#.NET application that allows a user to input some values in...
|
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,...
|
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: 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: 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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |