- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: socket peek buffer sizes
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2011 09:13 AM
01-13-2011 09:13 AM
socket peek buffer sizes
TIA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2011 09:16 AM
01-13-2011 09:16 AM
Re: socket peek buffer sizes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 09:32 AM
02-23-2011 09:32 AM
Re: socket peek buffer sizes
#if 0
printf("peeking %d bytes | ",peek_count);
status = sys$qiow(0,conn_channel,IO$_READVBLK,&iosb,0,0,cursor, peek_count,0,TCPIP$C_MSG_PEEK,0,0);
EXIT_IF_BAD(status,iosb);
if (iosb.iosb$w_bcnt == 0)
break;
int count = iosb.iosb$w_bcnt;
printf("peeked %d and now reading\n",iosb.iosb$w_bcnt);
status = sys$qiow(0,conn_channel, IO$_READVBLK, &iosb,0,0, cursor,count,0, 0,0,0 );
EXIT_IF_BAD(status,iosb);
if (count != iosb.iosb$w_bcnt)
printf("count mismatch, expd/got = %d/%d\n",count,iosb.iosb$w_bcnt);
#else
printf("reading %d |",peek_count);
status = sys$qiow(0,conn_channel, IO$_READVBLK, &iosb,0,0, cursor,peek_count,0, 0,0,0 );
EXIT_IF_BAD(status,iosb);
printf("got %d\n",iosb.iosb$w_bcnt);
#endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 12:24 PM
02-23-2011 12:24 PM
Re: socket peek buffer sizes
/Guenther
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 01:04 PM
02-23-2011 01:04 PM
Re: socket peek buffer sizes
It may help to see how you created the socket. Please include the values of any constants. If you can work out the device name, the output of SHOW DEVICE/FULL BGnnnn might also be interesting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 01:06 PM
02-23-2011 01:06 PM
Re: socket peek buffer sizes
The loop terminates when a certain string is found in the stream, or when howmuch = 0.
The code was written conditionally in two ways... One with a peek, one w/o a peek. The results are identical: the QIO completion size always maxes out at 1024 bytes.
Additionally, there is an 'interactive' part of this program that issues a "command" to the partner, prompting the partner to send a 5 byte response. Even though I issue a 64 byte read, I always get a 5 byte I/O completion. How does this work? Is there an inter-byte timeout that causes the driver to complete the I/O? IOW, why doesn't my 64 byte read block?
If I am correct in this "inter-byte timeout" assumption, is it possible that my network partner is pausing after it transmits every 1024 bytes? The delay might be long enough for the driver to then complete the I/O and force me to issue additional reads. I'd like to be able to increase this "inter-byte timeout" so that I can reduce the number of QIOs required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 02:11 PM
02-23-2011 02:11 PM
Re: socket peek buffer sizes
conn_sockchar.prot = TCPIP$C_TCP;
conn_sockchar.type = TCPIP$C_STREAM;
conn_sockchar.af = TCPIP$C_AF_INET;
struct timeval tmo={15,0}; // 2 second timeout on any I/O
tmo_itemlist.length = sizeof(tmo);
tmo_itemlist.type = TCPIP$C_RCVTIMEO;
tmo_itemlist.address = &tmo;
sockopt_itemlist.length = sizeof(tmo_itemlist);
sockopt_itemlist.type = TCPIP$C_SOCKOPT;
sockopt_itemlist.address = &tmo_itemlist;
// whom are we connecting to?
CLEAR(serv_addr);
serv_addr.sin_family = TCPIP$C_AF_INET;
serv_addr.sin_port = htons(atoi(argv[2])); // second arg is port number
// set up socket type
status = sys$qiow(0, conn_channel, IO$_SETMODE, &iosb, 0, 0, &conn_sockchar, 0, 0, 0, 0, 0 );
EXIT_IF_BAD(status,iosb);
// set up socket timeout
status = sys$qiow(0, conn_channel, IO$_SETMODE, &iosb, 0, 0, 0, 0, 0, 0, &sockopt_itemlist, 0 );
EXIT_IF_BAD(status,iosb);
// connect to remote port
status = sys$qiow(0, conn_channel, IO$_ACCESS, &iosb, 0, 0, 0, 0, &serv_itemlist, 0, 0, 0 );
EXIT_IF_BAD(status,iosb);
// Send the prompt - a CR
status = sys$qiow(0,conn_channel, IO$_WRITEVBLK, &iosb, 0, 0, "\r", 1, 0, 0, 0, 0);
EXIT_IF_BAD(status,iosb);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 02:13 PM
02-23-2011 02:13 PM
Re: socket peek buffer sizes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 03:49 PM
02-23-2011 03:49 PM
Re: socket peek buffer sizes
You actually specified that you have a read buffer of 64 bytes. If there are only 5 bytes in the buffer then that's is what you get.
Typically with TCP/IP - a STREAM protocol - you have to read in a loop and extract your data. There is no gurantee on the amount of data you may get with a read.
To change the default internal read buffer size do a IO$_SETMODE with TCPIP$C_RCVBUF.
But no matter how large you make all the buffers (program's private or system buffer) the data stream typically is "hacked" into smaller pieces.
Btw. the timeout only works if NO data has been received so far. Once a byte or more is in the system buffer the QIO calls returns when either there is no more data in the system buffer or your program buffer has been filled.
/Guenther
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 05:55 AM
02-24-2011 05:55 AM
Re: socket peek buffer sizes
Issuing a QIO on a stream isn't the same as issuing a QIO on a disk device. There's no way to know if there's more in the stream coming, so the driver has to make a decision when to complete the I/O.
The streams I am reading are well over 20,000 bytes long. If I issue a 50,000 byte QIOW read, I'd expect to block until all 50,000 bytes arrive. This is not the case. Similarly, the 64 byte read terminates after only 5 bytes have arrived. The driver decides to complete the I/O well before the requested number of bytes arrive. So what criteria does the driver use to complete the I/O? The driver must use some sort of "no-activity" timer, or perhaps it uses the size of a single transport that was received off the wire. If there is a timer, I am asking if there is any way to tune it.
Thanks,
Elli
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 07:03 AM
02-24-2011 07:03 AM
Re: socket peek buffer sizes
Ah, this old chestnut.
As you quite correctly state, TCP provides a stream of data.
And you're presuming to treat that stream as a record device.
It's not, unfortunately.
UDP does give you something closer to the record-oriented model. (Depending on exactly what is going on, UDP multicasts or even raw Ethernet datagrams can be a pretty handy solution to some classes of application problems, but I digress.)
TCP is free to give you 50,000 separate I/Os of 1 byte each or the full 50,000 bytes in one shot. Or 49,999 hits of 1 byte each, and then 50,000 bytes containing the last byte and most of the next transfer. Or any combination between that.
With TCP-based application communications, you get to do the segmentation and window processing in your code. Attempts to use timers to segment TCP traffic into records will tend to combine with the intervening IP routers and switches and other application traffic to conspire to find edge cases in socket code, too.
I'd suggest looking for middleware. Socket-level programming is something like programming assembler. It's possible, functional, feasible and such, but it's usually easier to punt on that and to use available networking libraries and available middleware packages. Rolling your own is something that involves, well, dealing with TCP streams and buffers and such. And you probably have application and customer code to write, rather than all of the glue code involved with socket programming.
If you can't migrate to a middleware interface into the IP network (and there are certainly reasons why VMS application programmers might not find that feasible) then you'll have to deal with the sliding window yourself. It's common to see a 2x buffer (or more) for the reads, and to aim the I/Os at the next available byte in the buffer. Basically assembling the incoming data into the record structures.
Double-buffering a TCP stream gets a little more ugly (and can involve rather more buffer copies than might be pleasant to perform on a busy server), as you don't really know how much you're going to get in response to each read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 07:12 AM
02-24-2011 07:12 AM
Re: socket peek buffer sizes
The driver does not wait; it just delivers as soon as something shows up, unless I provide the IO$M_LOCKBUF qualifier, in which case the I/O won't complete until I receive all the bytes I ask for or my partner closes the connection. Unfortunately, that's not an option for me.
Thanks for the help. I just wanted an explanation. My code works fine; I just thought I could tweak things a bit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 08:12 AM
02-24-2011 08:12 AM
Re: socket peek buffer sizes
Good ole DECnet made life much easier! A true record oriented protocol.
/Guenther
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 08:15 AM
02-24-2011 08:15 AM
Re: socket peek buffer sizes
/Guenther
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 08:22 AM
02-24-2011 08:22 AM
Re: socket peek buffer sizes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 10:12 AM
02-24-2011 10:12 AM
Re: socket peek buffer sizes
To change the default internal read buffer size do a IO$_SETMODE with TCPIP$C_RCVBUF.
I haven't played much with that but I doubt you'll see a significant performance gain with larger RCVBUF values.
/Guenther
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 12:00 PM
02-24-2011 12:00 PM
Re: socket peek buffer sizes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 12:42 PM
02-24-2011 12:42 PM
Re: socket peek buffer sizes
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 03:02 PM
02-24-2011 03:02 PM
Re: socket peek buffer sizes
I never am. ;-)
/Guenther