Solved

size of named pipe

Posted on 2001-07-26
8
649 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
ID: 6322255
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
ID: 6322808
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
ID: 6322835
I saw, this would be very much work.

Is it possible to increase the maximum size of the ctl part ?
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 5

Expert Comment

by:paulqna
ID: 6323915
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
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 6326946
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
ID: 6331584
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
ID: 6334420
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
ID: 6486245
I hoped I wouldn't need to do that...
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to check for shares on HP-UX 1 59
Sed question 2 86
Python Assistance 7 81
How do disable only TLSv1.0 in Oracle Sun One 7.1 Server 9 98
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

809 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