Discussion:
[hercules-390] Storage Limit for LCS device
reichmanjoe@gmail.com [hercules-390]
2017-09-24 21:28:17 UTC
Permalink
Hi


I am trying to write via TCP/IP 5600 bytes seems like the write works okay but the read takes two reads to get the entire data is there a limit to the buffer size using LCS device


I am using Fish's Tuntap


thanks
'\'Fish\' (David B. Trout)' david.b.trout@gmail.com [hercules-390]
2017-09-24 22:39:48 UTC
Permalink
Post by ***@gmail.com [hercules-390]
I am trying to write via TCP/IP 5600 bytes seems like the write
works okay but the read takes two reads to get the entire data
How are you "reading/writing via TCP/IP"? What does that mean? You need to learn how to ask clearer questions by providing more detail/specifics, Joe!

Are you calling into CTCI-WIN's TunTap64.dll 'tuntap-read' function directly yourself? If so, please be aware that it is designed to only return Ethernet FRAMES or IP PACKETS only. However the Windows host constructs its frames/packets is the same way that the WinPCap driver captures them and thus the same way they are delivered back to your program via the 'tuntap_read' function.
Post by ***@gmail.com [hercules-390]
is there a limit to the buffer size using LCS device
For Hercules LCS devices it is the "LCS_PortThread" function that calls into CTCI-WIN to retrieve its Ethernet frames, and looking at the code it uses a buffer size of 2048 bytes.
Post by ***@gmail.com [hercules-390]
I am using Fish's Tuntap
If you are calling into CTCI-WIN's "TunTap64.dll" directly yourself (i.e. calling the 'tuntap32_read' function directly yourself (see header tt32api.h)), the buffer size you specify in your call to 'tuntap_read' in conjunction with the Windows host adapter's maximum supported packet size (as reported by TTTest's "MaxPacketLen" value) determines the maximum number of bytes that 'tuntap_read' will ever return. As long as your specified buffer size is larger than the host adapter's "MaxPacketLen" value, 'tuntap_read' should always return a complete packet back to you.

What are you trying to do, Joe, and how are you currently trying to do it?

More importantly, WHAT are you trying to do? The way you're trying to do it might not be the best way.
--
"Fish" (David B. Trout)
Software Development Laboratories
http://www.softdevlabs.com
mail: ***@softdevlabs.com
'Joseph Reichman' reichmanjoe@gmail.com [hercules-390]
2017-09-24 22:54:36 UTC
Permalink
I was looking at the buffer size I think I am getting 2048 bytes on the first receive



Thanks



From: hercules-***@yahoogroups.com [mailto:hercules-***@yahoogroups.com]
Sent: Sunday, September 24, 2017 6:40 PM
To: hercules-***@yahoogroups.com
Subject: RE: [hercules-390] Storage Limit for LCS device
Post by ***@gmail.com [hercules-390]
I am trying to write via TCP/IP 5600 bytes seems like the write
works okay but the read takes two reads to get the entire data
How are you "reading/writing via TCP/IP"? What does that mean? You need to learn how to ask clearer questions by providing more detail/specifics, Joe!

Are you calling into CTCI-WIN's TunTap64.dll 'tuntap-read' function directly yourself? If so, please be aware that it is designed to only return Ethernet FRAMES or IP PACKETS only. However the Windows host constructs its frames/packets is the same way that the WinPCap driver captures them and thus the same way they are delivered back to your program via the 'tuntap_read' function.
Post by ***@gmail.com [hercules-390]
is there a limit to the buffer size using LCS device
For Hercules LCS devices it is the "LCS_PortThread" function that calls into CTCI-WIN to retrieve its Ethernet frames, and looking at the code it uses a buffer size of 2048 bytes.
Post by ***@gmail.com [hercules-390]
I am using Fish's Tuntap
If you are calling into CTCI-WIN's "TunTap64.dll" directly yourself (i.e. calling the 'tuntap32_read' function directly yourself (see header tt32api.h)), the buffer size you specify in your call to 'tuntap_read' in conjunction with the Windows host adapter's maximum supported packet size (as reported by TTTest's "MaxPacketLen" value) determines the maximum number of bytes that 'tuntap_read' will ever return. As long as your specified buffer size is larger than the host adapter's "MaxPacketLen" value, 'tuntap_read' should always return a complete packet back to you.

What are you trying to do, Joe, and how are you currently trying to do it?

More importantly, WHAT are you trying to do? The way you're trying to do it might not be the best way.
--
"Fish" (David B. Trout)
Software Development Laboratories
http://www.softdevlabs.com
mail: ***@softdevlabs.com <mailto:***@softdevlabs.com>
Jon Perryman jperryma@pacbell.net [hercules-390]
2017-09-25 01:31:19 UTC
Permalink
Repeating what Fish asked? What are you doing (not how you are diagnosing it). Is it ASM program running in z/OS or is it a modification to hercules? Which TCP calls did you issue? Is it blocking or non-blocking? Is it UDP or TCP? We need some sort of details. .
Regards, Jon.

On Sunday, September 24, 2017 3:54 PM, "'Joseph Reichman' ***@gmail.com    I was looking at the buffer size I think I am getting 2048 bytes on the first receive #yiv8366455504 #yiv8366455504 -- #yiv8366455504ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv8366455504 #yiv8366455504ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv8366455504 #yiv8366455504ygrp-mkp #yiv8366455504hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv8366455504 #yiv8366455504ygrp-mkp #yiv8366455504ads {margin-bottom:10px;}#yiv8366455504 #yiv8366455504ygrp-mkp .yiv8366455504ad {padding:0 0;}#yiv8366455504 #yiv8366455504ygrp-mkp .yiv8366455504ad p {margin:0;}#yiv8366455504 #yiv8366455504ygrp-mkp .yiv8366455504ad a {color:#0000ff;text-decoration:none;}#yiv8366455504 #yiv8366455504ygrp-sponsor #yiv8366455504ygrp-lc {font-family:Arial;}#yiv8366455504 #yiv8366455504ygrp-sponsor #yiv8366455504ygrp-lc #yiv8366455504hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv8366455504 #yiv8366455504ygrp-sponsor #yiv8366455504ygrp-lc .yiv8366455504ad {margin-bottom:10px;padding:0 0;}#yiv8366455504 #yiv8366455504actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv8366455504 #yiv8366455504activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv8366455504 #yiv8366455504activity span {font-weight:700;}#yiv8366455504 #yiv8366455504activity span:first-child {text-transform:uppercase;}#yiv8366455504 #yiv8366455504activity span a {color:#5085b6;text-decoration:none;}#yiv8366455504 #yiv8366455504activity span span {color:#ff7900;}#yiv8366455504 #yiv8366455504activity span .yiv8366455504underline {text-decoration:underline;}#yiv8366455504 .yiv8366455504attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv8366455504 .yiv8366455504attach div a {text-decoration:none;}#yiv8366455504 .yiv8366455504attach img {border:none;padding-right:5px;}#yiv8366455504 .yiv8366455504attach label {display:block;margin-bottom:5px;}#yiv8366455504 .yiv8366455504attach label a {text-decoration:none;}#yiv8366455504 blockquote {margin:0 0 0 4px;}#yiv8366455504 .yiv8366455504bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv8366455504 .yiv8366455504bold a {text-decoration:none;}#yiv8366455504 dd.yiv8366455504last p a {font-family:Verdana;font-weight:700;}#yiv8366455504 dd.yiv8366455504last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv8366455504 dd.yiv8366455504last p span.yiv8366455504yshortcuts {margin-right:0;}#yiv8366455504 div.yiv8366455504attach-table div div a {text-decoration:none;}#yiv8366455504 div.yiv8366455504attach-table {width:400px;}#yiv8366455504 div.yiv8366455504file-title a, #yiv8366455504 div.yiv8366455504file-title a:active, #yiv8366455504 div.yiv8366455504file-title a:hover, #yiv8366455504 div.yiv8366455504file-title a:visited {text-decoration:none;}#yiv8366455504 div.yiv8366455504photo-title a, #yiv8366455504 div.yiv8366455504photo-title a:active, #yiv8366455504 div.yiv8366455504photo-title a:hover, #yiv8366455504 div.yiv8366455504photo-title a:visited {text-decoration:none;}#yiv8366455504 div#yiv8366455504ygrp-mlmsg #yiv8366455504ygrp-msg p a span.yiv8366455504yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv8366455504 .yiv8366455504green {color:#628c2a;}#yiv8366455504 .yiv8366455504MsoNormal {margin:0 0 0 0;}#yiv8366455504 o {font-size:0;}#yiv8366455504 #yiv8366455504photos div {float:left;width:72px;}#yiv8366455504 #yiv8366455504photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv8366455504 #yiv8366455504photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv8366455504 #yiv8366455504reco-category {font-size:77%;}#yiv8366455504 #yiv8366455504reco-desc {font-size:77%;}#yiv8366455504 .yiv8366455504replbq {margin:4px;}#yiv8366455504 #yiv8366455504ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv8366455504 #yiv8366455504ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv8366455504 #yiv8366455504ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv8366455504 #yiv8366455504ygrp-mlmsg select, #yiv8366455504 input, #yiv8366455504 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv8366455504 #yiv8366455504ygrp-mlmsg pre, #yiv8366455504 code {font:115% monospace;}#yiv8366455504 #yiv8366455504ygrp-mlmsg * {line-height:1.22em;}#yiv8366455504 #yiv8366455504ygrp-mlmsg #yiv8366455504logo {padding-bottom:10px;}#yiv8366455504 #yiv8366455504ygrp-msg p a {font-family:Verdana;}#yiv8366455504 #yiv8366455504ygrp-msg p#yiv8366455504attach-count span {color:#1E66AE;font-weight:700;}#yiv8366455504 #yiv8366455504ygrp-reco #yiv8366455504reco-head {color:#ff7900;font-weight:700;}#yiv8366455504 #yiv8366455504ygrp-reco {margin-bottom:20px;padding:0px;}#yiv8366455504 #yiv8366455504ygrp-sponsor #yiv8366455504ov li a {font-size:130%;text-decoration:none;}#yiv8366455504 #yiv8366455504ygrp-sponsor #yiv8366455504ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv8366455504 #yiv8366455504ygrp-sponsor #yiv8366455504ov ul {margin:0;padding:0 0 0 8px;}#yiv8366455504 #yiv8366455504ygrp-text {font-family:Georgia;}#yiv8366455504 #yiv8366455504ygrp-text p {margin:0 0 1em 0;}#yiv8366455504 #yiv8366455504ygrp-text tt {font-size:120%;}#yiv8366455504 #yiv8366455504ygrp-vital ul li:last-child {border-right:none !important;}#yiv8366455504
Joseph Reichman reichmanjoe@gmail.com [hercules-390]
2017-09-25 02:22:33 UTC
Permalink
Yes it is a asm program doing a tcp/ip write the return code indicates that 5600 bytes were written

Yet in windows on the CAsynsocket::receive

It takes 2 receives to get that data
The CAsynsocket::OnReceive gets called twice to get that data
Post by Jon Perryman ***@pacbell.net [hercules-390]
Repeating what Fish asked? What are you doing (not how you are diagnosing it). Is it ASM program running in z/OS or is it a modification to hercules? Which TCP calls did you issue? Is it blocking or non-blocking? Is it UDP or TCP? We need some sort of details. .
Regards, Jon.
I was looking at the buffer size I think I am getting 2048 bytes on the first receive
Jon Perryman jperryma@pacbell.net [hercules-390]
2017-09-25 03:27:26 UTC
Permalink
From your response, I'm guessing that your windows program is running non-blocking therefore it will receive the data that is available (not data sent). This is standard TCP. I do robotics and automation which must run non-blocking. This is exactly what I would expect to see.
Regards, Jon.  

On Sunday, September 24, 2017 7:22 PM, "Joseph Reichman ***@gmail.com [hercules-390]" <hercules-***@yahoogroups.com> wrote:

Yes it is a asm  program doing a tcp/ip write the return code indicates that 5600 bytes were written 
Yet in windows on the CAsynsocket::receive 
It takes 2 receives to get that data The CAsynsocket::OnReceive gets called twice to get that data  #yiv5988562027 #yiv5988562027 -- #yiv5988562027ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv5988562027 #yiv5988562027ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv5988562027 #yiv5988562027ygrp-mkp #yiv5988562027hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv5988562027 #yiv5988562027ygrp-mkp #yiv5988562027ads {margin-bottom:10px;}#yiv5988562027 #yiv5988562027ygrp-mkp .yiv5988562027ad {padding:0 0;}#yiv5988562027 #yiv5988562027ygrp-mkp .yiv5988562027ad p {margin:0;}#yiv5988562027 #yiv5988562027ygrp-mkp .yiv5988562027ad a {color:#0000ff;text-decoration:none;}#yiv5988562027 #yiv5988562027ygrp-sponsor #yiv5988562027ygrp-lc {font-family:Arial;}#yiv5988562027 #yiv5988562027ygrp-sponsor #yiv5988562027ygrp-lc #yiv5988562027hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv5988562027 #yiv5988562027ygrp-sponsor #yiv5988562027ygrp-lc .yiv5988562027ad {margin-bottom:10px;padding:0 0;}#yiv5988562027 #yiv5988562027actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv5988562027 #yiv5988562027activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv5988562027 #yiv5988562027activity span {font-weight:700;}#yiv5988562027 #yiv5988562027activity span:first-child {text-transform:uppercase;}#yiv5988562027 #yiv5988562027activity span a {color:#5085b6;text-decoration:none;}#yiv5988562027 #yiv5988562027activity span span {color:#ff7900;}#yiv5988562027 #yiv5988562027activity span .yiv5988562027underline {text-decoration:underline;}#yiv5988562027 .yiv5988562027attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv5988562027 .yiv5988562027attach div a {text-decoration:none;}#yiv5988562027 .yiv5988562027attach img {border:none;padding-right:5px;}#yiv5988562027 .yiv5988562027attach label {display:block;margin-bottom:5px;}#yiv5988562027 .yiv5988562027attach label a {text-decoration:none;}#yiv5988562027 blockquote {margin:0 0 0 4px;}#yiv5988562027 .yiv5988562027bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv5988562027 .yiv5988562027bold a {text-decoration:none;}#yiv5988562027 dd.yiv5988562027last p a {font-family:Verdana;font-weight:700;}#yiv5988562027 dd.yiv5988562027last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv5988562027 dd.yiv5988562027last p span.yiv5988562027yshortcuts {margin-right:0;}#yiv5988562027 div.yiv5988562027attach-table div div a {text-decoration:none;}#yiv5988562027 div.yiv5988562027attach-table {width:400px;}#yiv5988562027 div.yiv5988562027file-title a, #yiv5988562027 div.yiv5988562027file-title a:active, #yiv5988562027 div.yiv5988562027file-title a:hover, #yiv5988562027 div.yiv5988562027file-title a:visited {text-decoration:none;}#yiv5988562027 div.yiv5988562027photo-title a, #yiv5988562027 div.yiv5988562027photo-title a:active, #yiv5988562027 div.yiv5988562027photo-title a:hover, #yiv5988562027 div.yiv5988562027photo-title a:visited {text-decoration:none;}#yiv5988562027 div#yiv5988562027ygrp-mlmsg #yiv5988562027ygrp-msg p a span.yiv5988562027yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv5988562027 .yiv5988562027green {color:#628c2a;}#yiv5988562027 .yiv5988562027MsoNormal {margin:0 0 0 0;}#yiv5988562027 o {font-size:0;}#yiv5988562027 #yiv5988562027photos div {float:left;width:72px;}#yiv5988562027 #yiv5988562027photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv5988562027 #yiv5988562027photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv5988562027 #yiv5988562027reco-category {font-size:77%;}#yiv5988562027 #yiv5988562027reco-desc {font-size:77%;}#yiv5988562027 .yiv5988562027replbq {margin:4px;}#yiv5988562027 #yiv5988562027ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv5988562027 #yiv5988562027ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv5988562027 #yiv5988562027ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv5988562027 #yiv5988562027ygrp-mlmsg select, #yiv5988562027 input, #yiv5988562027 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv5988562027 #yiv5988562027ygrp-mlmsg pre, #yiv5988562027 code {font:115% monospace;}#yiv5988562027 #yiv5988562027ygrp-mlmsg * {line-height:1.22em;}#yiv5988562027 #yiv5988562027ygrp-mlmsg #yiv5988562027logo {padding-bottom:10px;}#yiv5988562027 #yiv5988562027ygrp-msg p a {font-family:Verdana;}#yiv5988562027 #yiv5988562027ygrp-msg p#yiv5988562027attach-count span {color:#1E66AE;font-weight:700;}#yiv5988562027 #yiv5988562027ygrp-reco #yiv5988562027reco-head {color:#ff7900;font-weight:700;}#yiv5988562027 #yiv5988562027ygrp-reco {margin-bottom:20px;padding:0px;}#yiv5988562027 #yiv5988562027ygrp-sponsor #yiv5988562027ov li a {font-size:130%;text-decoration:none;}#yiv5988562027 #yiv5988562027ygrp-sponsor #yiv5988562027ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv5988562027 #yiv5988562027ygrp-sponsor #yiv5988562027ov ul {margin:0;padding:0 0 0 8px;}#yiv5988562027 #yiv5988562027ygrp-text {font-family:Georgia;}#yiv5988562027 #yiv5988562027ygrp-text p {margin:0 0 1em 0;}#yiv5988562027 #yiv5988562027ygrp-text tt {font-size:120%;}#yiv5988562027 #yiv5988562027ygrp-vital ul li:last-child {border-right:none !important;}#yiv5988562027
Joseph Reichman reichmanjoe@gmail.com [hercules-390]
2017-09-25 03:39:47 UTC
Permalink
So if I do a ioctl to change it to blocking I'll get all
The data at once

It is Interfering with my logic as the data is populated in a dialog box
And I end up with two dialog boxes

Thanks
Post by Jon Perryman ***@pacbell.net [hercules-390]
From your response, I'm guessing that your windows program is running non-blocking therefore it will receive the data that is available (not data sent). This is standard TCP. I do robotics and automation which must run non-blocking. This is exactly what I would expect to see.
Regards, Jon.
Yes it is a asm program doing a tcp/ip write the return code indicates that 5600 bytes were written
Yet in windows on the CAsynsocket::receive
It takes 2 receives to get that data
The CAsynsocket::OnReceive gets called twice to get that data
mcisho@yahoo.com [hercules-390]
2017-09-25 15:38:33 UTC
Permalink
No, blocking/non-blocking has nothing to do with the size of the received data. You have to code your application to cope with data arriving in unpredictable quantities.
Joseph Reichman reichmanjoe@gmail.com [hercules-390]
2017-09-25 15:41:17 UTC
Permalink
Thanks
Post by ***@yahoo.com [hercules-390]
No, blocking/non-blocking has nothing to do with the size of the received data. You have to code your application to cope with data arriving in unpredictable quantities.
Jon Perryman jperryma@pacbell.net [hercules-390]
2017-09-25 23:25:15 UTC
Permalink
A blocking receive without a timeout is a predictable amount. Discussions about blocking/non-blocking discuss the various methods / attributes that are used to receive socket data. Unless you have a better suggestion, this would be a good starting point for Joe to understand and solve his problem.
Regards, Jon.

On Monday, September 25, 2017 8:38 AM, "***@yahoo.com [hercules-390]" <hercules-***@yahoogroups.com> wrote:


  No, blocking/non-blocking has nothing to do with the size of the received data. You have to code your application to cope with data arriving in unpredictable quantities.
#yiv6313039423 #yiv6313039423 -- #yiv6313039423ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv6313039423 #yiv6313039423ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv6313039423 #yiv6313039423ygrp-mkp #yiv6313039423hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv6313039423 #yiv6313039423ygrp-mkp #yiv6313039423ads {margin-bottom:10px;}#yiv6313039423 #yiv6313039423ygrp-mkp .yiv6313039423ad {padding:0 0;}#yiv6313039423 #yiv6313039423ygrp-mkp .yiv6313039423ad p {margin:0;}#yiv6313039423 #yiv6313039423ygrp-mkp .yiv6313039423ad a {color:#0000ff;text-decoration:none;}#yiv6313039423 #yiv6313039423ygrp-sponsor #yiv6313039423ygrp-lc {font-family:Arial;}#yiv6313039423 #yiv6313039423ygrp-sponsor #yiv6313039423ygrp-lc #yiv6313039423hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv6313039423 #yiv6313039423ygrp-sponsor #yiv6313039423ygrp-lc .yiv6313039423ad {margin-bottom:10px;padding:0 0;}#yiv6313039423 #yiv6313039423actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv6313039423 #yiv6313039423activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv6313039423 #yiv6313039423activity span {font-weight:700;}#yiv6313039423 #yiv6313039423activity span:first-child {text-transform:uppercase;}#yiv6313039423 #yiv6313039423activity span a {color:#5085b6;text-decoration:none;}#yiv6313039423 #yiv6313039423activity span span {color:#ff7900;}#yiv6313039423 #yiv6313039423activity span .yiv6313039423underline {text-decoration:underline;}#yiv6313039423 .yiv6313039423attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv6313039423 .yiv6313039423attach div a {text-decoration:none;}#yiv6313039423 .yiv6313039423attach img {border:none;padding-right:5px;}#yiv6313039423 .yiv6313039423attach label {display:block;margin-bottom:5px;}#yiv6313039423 .yiv6313039423attach label a {text-decoration:none;}#yiv6313039423 blockquote {margin:0 0 0 4px;}#yiv6313039423 .yiv6313039423bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv6313039423 .yiv6313039423bold a {text-decoration:none;}#yiv6313039423 dd.yiv6313039423last p a {font-family:Verdana;font-weight:700;}#yiv6313039423 dd.yiv6313039423last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv6313039423 dd.yiv6313039423last p span.yiv6313039423yshortcuts {margin-right:0;}#yiv6313039423 div.yiv6313039423attach-table div div a {text-decoration:none;}#yiv6313039423 div.yiv6313039423attach-table {width:400px;}#yiv6313039423 div.yiv6313039423file-title a, #yiv6313039423 div.yiv6313039423file-title a:active, #yiv6313039423 div.yiv6313039423file-title a:hover, #yiv6313039423 div.yiv6313039423file-title a:visited {text-decoration:none;}#yiv6313039423 div.yiv6313039423photo-title a, #yiv6313039423 div.yiv6313039423photo-title a:active, #yiv6313039423 div.yiv6313039423photo-title a:hover, #yiv6313039423 div.yiv6313039423photo-title a:visited {text-decoration:none;}#yiv6313039423 div#yiv6313039423ygrp-mlmsg #yiv6313039423ygrp-msg p a span.yiv6313039423yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv6313039423 .yiv6313039423green {color:#628c2a;}#yiv6313039423 .yiv6313039423MsoNormal {margin:0 0 0 0;}#yiv6313039423 o {font-size:0;}#yiv6313039423 #yiv6313039423photos div {float:left;width:72px;}#yiv6313039423 #yiv6313039423photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv6313039423 #yiv6313039423photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv6313039423 #yiv6313039423reco-category {font-size:77%;}#yiv6313039423 #yiv6313039423reco-desc {font-size:77%;}#yiv6313039423 .yiv6313039423replbq {margin:4px;}#yiv6313039423 #yiv6313039423ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv6313039423 #yiv6313039423ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv6313039423 #yiv6313039423ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv6313039423 #yiv6313039423ygrp-mlmsg select, #yiv6313039423 input, #yiv6313039423 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv6313039423 #yiv6313039423ygrp-mlmsg pre, #yiv6313039423 code {font:115% monospace;}#yiv6313039423 #yiv6313039423ygrp-mlmsg * {line-height:1.22em;}#yiv6313039423 #yiv6313039423ygrp-mlmsg #yiv6313039423logo {padding-bottom:10px;}#yiv6313039423 #yiv6313039423ygrp-msg p a {font-family:Verdana;}#yiv6313039423 #yiv6313039423ygrp-msg p#yiv6313039423attach-count span {color:#1E66AE;font-weight:700;}#yiv6313039423 #yiv6313039423ygrp-reco #yiv6313039423reco-head {color:#ff7900;font-weight:700;}#yiv6313039423 #yiv6313039423ygrp-reco {margin-bottom:20px;padding:0px;}#yiv6313039423 #yiv6313039423ygrp-sponsor #yiv6313039423ov li a {font-size:130%;text-decoration:none;}#yiv6313039423 #yiv6313039423ygrp-sponsor #yiv6313039423ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv6313039423 #yiv6313039423ygrp-sponsor #yiv6313039423ov ul {margin:0;padding:0 0 0 8px;}#yiv6313039423 #yiv6313039423ygrp-text {font-family:Georgia;}#yiv6313039423 #yiv6313039423ygrp-text p {margin:0 0 1em 0;}#yiv6313039423 #yiv6313039423ygrp-text tt {font-size:120%;}#yiv6313039423 #yiv6313039423ygrp-vital ul li:last-child {border-right:none !important;}#yiv6313039423
mcisho@yahoo.com [hercules-390]
2017-09-26 09:48:06 UTC
Permalink
Sorry Jon but I disagree, a blocking receive, with or without a timeout, is not a predictable amount, except when small messages (i.e. approximately 500 bytes or less) are involved.

The quantity of data an individual recv call will receive is influenced by a whole range of factors outside of the receivers control, for example, the MTU(s) in use between the endpoints, the network utilization, the load on the sending and/or receiving systems, etc.

Joe has made the same assumption that pretty much everyone new to sockets programming has made (myself included), that because a lump of data of n bytes was sent, a lump of data of n bytes will be received.

Ian
Giuseppe Vitillaro giuseppe@vitillaro.org [hercules-390]
2017-09-26 11:26:55 UTC
Permalink
Post by ***@yahoo.com [hercules-390]
Sorry Jon but I disagree, a blocking receive, with or without a timeout,
is not a predictable amount, except when small messages (i.e.
approximately 500 bytes or less) are involved.
The quantity of data an individual recv call will receive is influenced
by a whole range of factors outside of the receivers control, for
example, the MTU(s) in use between the endpoints, the network
utilization, the load on the sending and/or receiving systems, etc.
Joe has made the same assumption that pretty much everyone new to
sockets programming has made (myself included), that because a lump of
data of n bytes was sent, a lump of data of n bytes will be received.
Ian
Yep. That the TCP socket model, at least for what I understand
from my Comer.

The size returned from a single read() on a socket is just
"unpredictable": you are reading a "stream of bytes" from the socket and
the size of the returned buffers, for each single read(), is influenced by
a great number of parameters.

You may send a single block of N bytes from one side and you may receive
any "partition" of such integer number N, (i_1,i_2,...,i_m), in m
reads from the other side, where (i_1 + i_2 + ... + i_m) = N.

The TCP/IP protocols may only assure that you will receive the correct
number of bytes in an unpredictable number of reads, the correct bytes, in
the correct order, but nothing else.

That's why, usually, over a TCP socket stream, you need an "application
protocol" which allow the applications on the two sides of the socket, to
send and receive application data.

Peppe.
Giuseppe Vitillaro giuseppe@vitillaro.org [hercules-390]
2017-09-26 15:25:57 UTC
Permalink
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
Post by ***@yahoo.com [hercules-390]
Sorry Jon but I disagree, a blocking receive, with or without a timeout,
is not a predictable amount, except when small messages (i.e.
approximately 500 bytes or less) are involved.
The quantity of data an individual recv call will receive is influenced
by a whole range of factors outside of the receivers control, for
example, the MTU(s) in use between the endpoints, the network
utilization, the load on the sending and/or receiving systems, etc.
Joe has made the same assumption that pretty much everyone new to
sockets programming has made (myself included), that because a lump of
data of n bytes was sent, a lump of data of n bytes will be received.
Ian
Yep. That the TCP socket model, at least for what I understand
from my Comer.
The size returned from a single read() on a socket is just
"unpredictable": you are reading a "stream of bytes" from the socket and
the size of the returned buffers, for each single read(), is influenced by
a great number of parameters.
You may send a single block of N bytes from one side and you may receive
any "partition" of such integer number N, (i_1,i_2,...,i_m), in m
reads from the other side, where (i_1 + i_2 + ... + i_m) = N.
The TCP/IP protocols may only assure that you will receive the correct
number of bytes in an unpredictable number of reads, the correct bytes, in
the correct order, but nothing else.
That's why, usually, over a TCP socket stream, you need an "application
protocol" which allow the applications on the two sides of the socket, to
send and receive application data.
Peppe.
One of the simpler application protocols which may be implemented over a
TCP socket, is a "message passing protocol", where the length of a
"message", a string of bytes for example, is encoded in "network format",
as the "header" of the message.

The "functions" htonl/ntohl, which are almost always presents, as
functions or macros, in any socket library, may be easily used to encode
such "header length" as an unsigned 32 bits integer, in an architecture
indipended format, the easier way to marshall/unmarshall application data.

In such a way, once the message "length" has been received
the message payload may be received looping until the whole
message is recovered in user space buffers:

ptr = (unsigned char *)msg;
...
for ( len = 0; len < length; len += l ) {
l = recv ( q.socket, ptr, length - len, 0 );
ptr += l;
}

The length header itself may be received, before the payload,
with exactly the same loop and a fixed "length" of "sizeof(uint32_t)".

That of course, beside error checking ...;-)

Peppe.
'\'Fish\' (David B. Trout)' david.b.trout@gmail.com [hercules-390]
2017-09-26 21:59:09 UTC
Permalink
Peppe (Giuseppe Vitillaro) wrote:

[...]
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
ptr = (unsigned char *)msg;
...
for ( len = 0; len < length; len += l ) {
l = recv ( q.socket, ptr, length - len, 0 );
ptr += l;
}
Which is exactly what the functions in Hercules's "hsocket.c" source member do.

As I said, Joe Teichman should take a look at them and adjust his CAsynsocket::receive logic to do the same thing.
--
"Fish" (David B. Trout)
Software Development Laboratories
http://www.softdevlabs.com
mail: ***@softdevlabs.com
Joseph Reichman reichmanjoe@gmail.com [hercules-390]
2017-09-26 22:11:11 UTC
Permalink
Reichman


Thanks :)
Post by '\'Fish\' (David B. Trout)' ***@gmail.com [hercules-390]
[...]
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
ptr = (unsigned char *)msg;
...
for ( len = 0; len < length; len += l ) {
l = recv ( q.socket, ptr, length - len, 0 );
ptr += l;
}
Which is exactly what the functions in Hercules's "hsocket.c" source member do.
As I said, Joe Teichman should take a look at them and adjust his CAsynsocket::receive logic to do the same thing.
--
"Fish" (David B. Trout)
Software Development Laboratories
http://www.softdevlabs.com
Giuseppe Vitillaro giuseppe@vitillaro.org [hercules-390]
2017-09-27 08:15:27 UTC
Permalink
Post by '\'Fish\' (David B. Trout)' ***@gmail.com [hercules-390]
[...]
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
ptr = (unsigned char *)msg;
...
for ( len = 0; len < length; len += l ) {
l = recv ( q.socket, ptr, length - len, 0 );
ptr += l;
}
Which is exactly what the functions in Hercules's "hsocket.c" source member do.
As I said, Joe Teichman should take a look at them and adjust his CAsynsocket::receive logic to do the same thing.
A short comment, which goes sideway to the topic of this thread, about
your words, David.

In my personal experience, at the core of most applications there are,
often, short fragments of code like this.

The fragments which do the "dirty job".

Beside the language, beside the coder, beside the developing framework,
beside the application, the "fragment" remain the same, identical
to itself, over decades ;-)

Peppe.
gah@ugcs.caltech.edu [hercules-390]
2017-09-27 18:29:20 UTC
Permalink
Yes, TCP is a stream protocol, such that the number of bytes in a send() is unrelated to the number you get in a recv().

If you need record boundaries, UDP sends whole packets (which might be fragmented and reassembled by IP) such that you do recv() the bytes that were sent.

If you need record boundaries with TCP, there is:

https://www.ietf.org/rfc/rfc1831.txt https://www.ietf.org/rfc/rfc1831.txt

which is used, for example, by NFS/TCP in the place where older NFS/UDP uses the UDP packet boundaries.
Joe Monk joemonk64@gmail.com [hercules-390]
2017-09-26 11:49:01 UTC
Permalink
Im not the Joe mentioned below, but TCP is a guaranteed transmission
protocol. If X number of bytes is sent, an ACK will not be returned to the
sender until that same number of bytes has been received by the receiver.
And the sender will keep on trying until those bytes are ACK'd.

It is the whole purpose of the sliding window protocol and selective
acknowledgements...

Joe
Post by ***@yahoo.com [hercules-390]
Sorry Jon but I disagree, a blocking receive, with or without a timeout,
is not a predictable amount, except when small messages (i.e. approximately
500 bytes or less) are involved.
The quantity of data an individual recv call will receive is influenced by
a whole range of factors outside of the receivers control, for example, the
MTU(s) in use between the endpoints, the network utilization, the load on
the sending and/or receiving systems, etc.
Joe has made the same assumption that pretty much everyone new to sockets
programming has made (myself included), that because a lump of data of n
bytes was sent, a lump of data of n bytes will be received.
Ian
Giuseppe Vitillaro giuseppe@vitillaro.org [hercules-390]
2017-09-26 14:45:56 UTC
Permalink
Post by Joe Monk ***@gmail.com [hercules-390]
Im not the Joe mentioned below, but TCP is a guaranteed transmission
protocol. If X number of bytes is sent, an ACK will not be returned to the
sender until that same number of bytes has been received by the receiver.
And the sender will keep on trying until those bytes are ACK'd.
It is the whole purpose of the sliding window protocol and selective
acknowledgements...
The TCP protocol stack grants that the bytes sent into the stream through
a connected socket are the the byte received, in the same order, from the
stream, but say nothing about the number of reads which have to be issued
to transfer that stream in the user space buffer on the receive side of
the socket.

Peppe.
'\'Fish\' (David B. Trout)' david.b.trout@gmail.com [hercules-390]
2017-09-26 21:54:23 UTC
Permalink
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
Post by Joe Monk ***@gmail.com [hercules-390]
Im not the Joe mentioned below, but TCP is a guaranteed
transmission protocol. If X number of bytes is sent, an
ACK will not be returned to the sender until that same number
of bytes has been received by the receiver. And the sender
will keep on trying until those bytes are ACK'd.
It is the whole purpose of the sliding window protocol and
selective acknowledgements...
The TCP protocol stack grants that the bytes sent into the stream
through a connected socket are the the byte received, in the same
order, from the stream, but say nothing about the number of reads
which have to be issued to transfer that stream in the user space
buffer on the receive side of the socket.
Bingo!

Jon Perryman hinted at it when he mentioned blocking/non-blocking sockets.

Ian Shorter (mcisho) then correctly pointed out that blocking/non-blocking mode of the socket technically has nothing to do with the problem (although whether the socket is blocking or non-blocking *will* exacerbate/confuse the issue. Non-blocking sockets take special care to use correctly).

Whether the socket is blocking or non-blocking (with or without a timeout value, i.e. whether you use a timeout doesn't matter), the number of bytes actually received is unpredictable.

Just because you do a "recv" (or on Linux a "read") for, say, 5000 bytes for example, DOESN'T mean when the recv/read completes that you actually received 500 bytes. You might have only received anywhere from 0 to 5000 bytes. You have to check your return code to know.

If you know ahead of time how many bytes you expect to receive (e.g. 5000), then you need to code your "receive socket data" function to loop doing multiple recv/reads until all expected 5000 bytes are received.

That's the purpose of the functions in the Hercules "hsocket.c" source member. Joe (Reichman) should do well to look at the functions in hsocket.c and see how they're coded. He needs to doing the same thing in his code.

Thank you Peppe.

And Jon.

And Ian.
--
"Fish" (David B. Trout)
Software Development Laboratories
http://www.softdevlabs.com
mail: ***@softdevlabs.com
Harold Grovesteen h.grovsteen@tx.rr.com [hercules-390]
2017-09-26 15:03:53 UTC
Permalink
Post by Joe Monk ***@gmail.com [hercules-390]
Im not the Joe mentioned below, but TCP is a guaranteed transmission
protocol. If X number of bytes is sent, an ACK will not be returned
to the sender until that same number of bytes has been received by
the receiver. And the sender will keep on trying until those bytes
are ACK'd.
It is the whole purpose of the sliding window protocol and selective
acknowledgements... 
Joe
 
Absolutely true.  But, the actions you are describing are taken by the
TCP stack itself, and are not visible to the application issuing the
send or receive requests.

Harold Grovesteen
Jon Perryman jperryma@pacbell.net [hercules-390]
2017-09-26 18:31:23 UTC
Permalink
Since I've never looked at blocking receive, I had to try it for myself. Returning available data is really dangerous design flaw. Even messages of 2 bytes cannot be trusted (TCP will slightly delay partially filled MTU's in the hopes that additional data will be sent). Small messages is not an exception. The smaller the message, the less likely you are to encounter this problem but my guess is that many transient errors get dismissed.
Jon. 

#yiv8799054219 -- #yiv8799054219ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv8799054219 #yiv8799054219ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv8799054219 #yiv8799054219ygrp-mkp #yiv8799054219hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv8799054219 #yiv8799054219ygrp-mkp #yiv8799054219ads {margin-bottom:10px;}#yiv8799054219 #yiv8799054219ygrp-mkp .yiv8799054219ad {padding:0 0;}#yiv8799054219 #yiv8799054219ygrp-mkp .yiv8799054219ad p {margin:0;}#yiv8799054219 #yiv8799054219ygrp-mkp .yiv8799054219ad a {color:#0000ff;text-decoration:none;}#yiv8799054219 #yiv8799054219ygrp-sponsor #yiv8799054219ygrp-lc {font-family:Arial;}#yiv8799054219 #yiv8799054219ygrp-sponsor #yiv8799054219ygrp-lc #yiv8799054219hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv8799054219 #yiv8799054219ygrp-sponsor #yiv8799054219ygrp-lc .yiv8799054219ad {margin-bottom:10px;padding:0 0;}#yiv8799054219 #yiv8799054219actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv8799054219 #yiv8799054219activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv8799054219 #yiv8799054219activity span {font-weight:700;}#yiv8799054219 #yiv8799054219activity span:first-child {text-transform:uppercase;}#yiv8799054219 #yiv8799054219activity span a {color:#5085b6;text-decoration:none;}#yiv8799054219 #yiv8799054219activity span span {color:#ff7900;}#yiv8799054219 #yiv8799054219activity span .yiv8799054219underline {text-decoration:underline;}#yiv8799054219 .yiv8799054219attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv8799054219 .yiv8799054219attach div a {text-decoration:none;}#yiv8799054219 .yiv8799054219attach img {border:none;padding-right:5px;}#yiv8799054219 .yiv8799054219attach label {display:block;margin-bottom:5px;}#yiv8799054219 .yiv8799054219attach label a {text-decoration:none;}#yiv8799054219 blockquote {margin:0 0 0 4px;}#yiv8799054219 .yiv8799054219bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv8799054219 .yiv8799054219bold a {text-decoration:none;}#yiv8799054219 dd.yiv8799054219last p a {font-family:Verdana;font-weight:700;}#yiv8799054219 dd.yiv8799054219last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv8799054219 dd.yiv8799054219last p span.yiv8799054219yshortcuts {margin-right:0;}#yiv8799054219 div.yiv8799054219attach-table div div a {text-decoration:none;}#yiv8799054219 div.yiv8799054219attach-table {width:400px;}#yiv8799054219 div.yiv8799054219file-title a, #yiv8799054219 div.yiv8799054219file-title a:active, #yiv8799054219 div.yiv8799054219file-title a:hover, #yiv8799054219 div.yiv8799054219file-title a:visited {text-decoration:none;}#yiv8799054219 div.yiv8799054219photo-title a, #yiv8799054219 div.yiv8799054219photo-title a:active, #yiv8799054219 div.yiv8799054219photo-title a:hover, #yiv8799054219 div.yiv8799054219photo-title a:visited {text-decoration:none;}#yiv8799054219 div#yiv8799054219ygrp-mlmsg #yiv8799054219ygrp-msg p a span.yiv8799054219yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv8799054219 .yiv8799054219green {color:#628c2a;}#yiv8799054219 .yiv8799054219MsoNormal {margin:0 0 0 0;}#yiv8799054219 o {font-size:0;}#yiv8799054219 #yiv8799054219photos div {float:left;width:72px;}#yiv8799054219 #yiv8799054219photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv8799054219 #yiv8799054219photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv8799054219 #yiv8799054219reco-category {font-size:77%;}#yiv8799054219 #yiv8799054219reco-desc {font-size:77%;}#yiv8799054219 .yiv8799054219replbq {margin:4px;}#yiv8799054219 #yiv8799054219ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv8799054219 #yiv8799054219ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv8799054219 #yiv8799054219ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv8799054219 #yiv8799054219ygrp-mlmsg select, #yiv8799054219 input, #yiv8799054219 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv8799054219 #yiv8799054219ygrp-mlmsg pre, #yiv8799054219 code {font:115% monospace;}#yiv8799054219 #yiv8799054219ygrp-mlmsg * {line-height:1.22em;}#yiv8799054219 #yiv8799054219ygrp-mlmsg #yiv8799054219logo {padding-bottom:10px;}#yiv8799054219 #yiv8799054219ygrp-msg p a {font-family:Verdana;}#yiv8799054219 #yiv8799054219ygrp-msg p#yiv8799054219attach-count span {color:#1E66AE;font-weight:700;}#yiv8799054219 #yiv8799054219ygrp-reco #yiv8799054219reco-head {color:#ff7900;font-weight:700;}#yiv8799054219 #yiv8799054219ygrp-reco {margin-bottom:20px;padding:0px;}#yiv8799054219 #yiv8799054219ygrp-sponsor #yiv8799054219ov li a {font-size:130%;text-decoration:none;}#yiv8799054219 #yiv8799054219ygrp-sponsor #yiv8799054219ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv8799054219 #yiv8799054219ygrp-sponsor #yiv8799054219ov ul {margin:0;padding:0 0 0 8px;}#yiv8799054219 #yiv8799054219ygrp-text {font-family:Georgia;}#yiv8799054219 #yiv8799054219ygrp-text p {margin:0 0 1em 0;}#yiv8799054219 #yiv8799054219ygrp-text tt {font-size:120%;}#yiv8799054219 #yiv8799054219ygrp-vital ul li:last-child {border-right:none !important;}#yiv8799054219 On Tuesday, September 26, 2017 2:48 AM, "***@yahoo.com [hercules-390]" <hercules-***@yahoogroups.com> wrote:

  Sorry Jon but I disagree, a blocking receive, with or without a timeout, is not a predictable amount, except when small messages (i.e. approximately 500 bytes or less) are involved.

The quantity of data an individual recv call will receive is influenced by a whole range of factors outside of the receivers control, for example, the MTU(s) in use between the endpoints, the network utilization, the load on the sending and/or receiving systems, etc.

Joe has made the same assumption that pretty much everyone new to sockets programming has made (myself included), that because a lump of data of n bytes was sent, a lump of data of n bytes will be received.
Peter Coghlan mailinglists@beyondthepale.ie [hercules-390]
2017-09-26 22:55:48 UTC
Permalink
Post by '\'Fish\' (David B. Trout)' ***@gmail.com [hercules-390]
[...]
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
ptr = (unsigned char *)msg;
...
for ( len = 0; len < length; len += l ) {
l = recv ( q.socket, ptr, length - len, 0 );
ptr += l;
}
Which is exactly what the functions in Hercules's "hsocket.c" source member do.
I have run into issues with this when writing device handling code for Hercules
and I am not convinced it is the right way to go.

My reasoning goes like this. Hercules is a multithreaded application. It
should never be spinning in a loop waiting for data to come in. It should
go and do something else instead.

If the socket in question is a non-blocking socket, the recv() is going to
quickly fail and set errno to EWOULDBLOCK each time around the loop until
the required data arrives. This is going to waste lots of CPU doing nothing.

If the socket in question is a blocking socket, the thread is going to get
hung up in the recv() until the required data arrives and it is not possible
to have the thread respond to anything else that it might need to such as
handle i/o going the other way in the case of a device thread, for example.

I think the above approach is reasonable for an application that can do
nothing else until the data it needs arrives but I think it is rarely the
right approach for an application like Hercules.

Regards,
Peter Coghlan.
Giuseppe Vitillaro giuseppe@vitillaro.org [hercules-390]
2017-09-27 08:06:33 UTC
Permalink
Post by Peter Coghlan ***@beyondthepale.ie [hercules-390]
Post by '\'Fish\' (David B. Trout)' ***@gmail.com [hercules-390]
[...]
Post by Giuseppe Vitillaro ***@vitillaro.org [hercules-390]
ptr = (unsigned char *)msg;
...
for ( len = 0; len < length; len += l ) {
l = recv ( q.socket, ptr, length - len, 0 );
ptr += l;
}
Which is exactly what the functions in Hercules's "hsocket.c" source member do.
I have run into issues with this when writing device handling code for Hercules
and I am not convinced it is the right way to go.
My reasoning goes like this. Hercules is a multithreaded application. It
should never be spinning in a loop waiting for data to come in. It should
go and do something else instead.
If the socket in question is a non-blocking socket, the recv() is going to
quickly fail and set errno to EWOULDBLOCK each time around the loop until
the required data arrives. This is going to waste lots of CPU doing nothing.
If the socket in question is a blocking socket, the thread is going to get
hung up in the recv() until the required data arrives and it is not possible
to have the thread respond to anything else that it might need to such as
handle i/o going the other way in the case of a device thread, for example.
I think the above approach is reasonable for an application that can do
nothing else until the data it needs arrives but I think it is rarely the
right approach for an application like Hercules.
Regards,
Peter Coghlan.
Then suddenly, "select()", raise over the horizon ... ;-)

Peppe.
Loading...