Solved

size of named pipe

Posted on 2001-07-26
8
643 Views
Last Modified: 2013-12-27
Hi All!

I have a problem with named pipes. I'm only able to send 1024 bytes with putpmsg. If I try to send more I get an error (ERANGE).

How can I change the maximum size of named pipes ?
0
Comment
Question by:superschlonz
  • 4
  • 2
  • 2
8 Comments
 
LVL 5

Expert Comment

by:paulqna
Comment Utility
Please look for strbuf in a file called stropts.h

On solaris this can be found in /usr/include/sys/stropts.h
0
 
LVL 3

Author Comment

by:superschlonz
Comment Utility
I'm using this structure (also tried to set maxlen=len instead of zero).

And I'm sure I was able to send up to about 3000 bytes some days ago. But after a lot of changes in my source code I always get an ERANGE error when sending 2828 bytes.

I wrote a little testprogram to find out how many bytes are accepted and it shows 1024 (for control part which we use).
And it also shows that I can send 5120 bytes for the data part.

For sending the data we use the ctl part and I'm sure that I didn't touch that. OK, now I'll try sending the data in the data part, perhaps it works.
0
 
LVL 3

Author Comment

by:superschlonz
Comment Utility
I saw, this would be very much work.

Is it possible to increase the maximum size of the ctl part ?
0
 
LVL 5

Expert Comment

by:paulqna
Comment Utility
Maybe you can find your answer here :
http://docsun.cso.uiuc.edu/cgi-bin/nph-dweb/ab2/coll.45.13/STREAMS/@Ab2TocView/24220

This example illustrates a simple loop, with the application reading data from the communications device, then writing the input back to the same device,
echoing all input back over the communications line. The program reads up to 1024 bytes at a time, and then writes the number of bytes just read.

read returns the available data, which can contain fewer than 1024 bytes. If no data is currently available at the stream head, read(2) blocks until data
arrives.
Simple Stream

#include <sys/fcntl.h>
#include <stdio.h>
main()
{
  char buf[1024];
  int fd, count;
   if ((fd = open("/dev/ttya", O_RDWR)) < 0) {
   perror("open failed");
   exit(1);
  }
  while ((count = read(fd, buf, sizeof(buf))) > 0) {
   if (write(fd, buf, count) != count) {
    perror("write failed");
    break;
   }
  }
  exit(0);
}
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 14

Expert Comment

by:chris_calabrese
Comment Utility
Pipe devices just aren't designed for this sort of thing.

You need  your writing program to buffer its output so it won't fill the pipe and you need your reading program to keep reading until it gets the whole thing.

Using stdio should solve the buffering problem easily enough.

If the reader knows the size of the structure it needs to read, then things are easy enough on the reading side too (just keep reading until you get the whole thing, as suggested by paulgna).  Otherwise you might need to prepend the structure with its size so the reader knows how much data it should expect to slurp up.
0
 
LVL 3

Author Comment

by:superschlonz
Comment Utility
Perhaps they aren't designed for that but they support it (at least since 2.6 and ReliantUNIX/SINIX since 5.42).

I cannot replace the mechanism because I need these bands for sending priorized messages (and because the software is very old and very complex).

This complexity was also the reason why I believed why my changes had nothing to do with the messages sent over the pipe. Now that I found it, I was able to reduce the maximum size to about 900 bytes again as was before my changes and it works.

But I'm still interested in increasing the size because I'm sure I'll run into this problem again and will perhaps not be able to do such a small workaround like this time.

I have also seen some kernel parameters for setting the size for ctl and data part of these system calls, but they aren't set int my /etc/system and default to 64kB.
0
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 50 total points
Comment Utility
You probably have to recompile the kernel to change this.  Don't remember what vbl deals with this anymore (used to know back when the default was 512 bytes and we used to change this all the time).
0
 
LVL 3

Author Comment

by:superschlonz
Comment Utility
I hoped I wouldn't need to do that...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now