⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getmsg.2

📁 7号信令功能代码,为开源代码
💻 2
字号:
'\" tr.\" -*- nroff -*-.\".\" @(#) getmsg.2,v 1.1.4.1 2004/01/12 23:45:03 brian Exp.\".\" =========================================================================.\".\" Copyright (C) 2001-2004  OpenSS7 Corp. <www.openss7.com>.\".\" All Rights Reserved..\".\" Permission is granted to make and distribute verbatim copies of this.\" manual provided the copyright notice and this permission notice are.\" preserved on all copies..\".\" Permission is granted to copy and distribute modified versions of this.\" manual under the conditions for verbatim copying, provided that the.\" entire resulting derived work is distributed under the terms of a.\" permission notice identical to this one.\" .\" Since the Linux kernel and libraries are constantly changing, this.\" manual page may be incorrect or out-of-date.  The author(s) assume no.\" responsibility for errors or omissions, or for damages resulting from.\" the use of the information contained herein.  The author(s) may not.\" have taken the same level of care in the production of this manual,.\" which is licensed free of charge, as they might when working.\" professionally..\" .\" Formatted or processed versions of this manual, if unaccompanied by.\" the source, must acknowledge the copyright and authors of this work..\".\" =========================================================================.\".\" Modified 2004/01/12 23:45:03 by brian.\".\" =========================================================================.so lis.macros.R1bracket-label "\fR[\fB" "\fR]" "\fR, \fB"no-default-databasedatabase lis.refsaccumulatemove-punctuationabbreviate Ajoin-authors ", " ", " " and "et-al " et al" 2 3abbreviate-label-ranges ".."sort-adjacent-labels.R2.\".\".TH GETMSG 2 "2004/01/12 23:45:03" "LiS-2_16_18-8" "Linux STREAMS System Calls".SH NAMEgetmsg \- get next message off a stream.SH SYNOPSIS.PP.B #include <stropts.h>.HP 8.BI "int " retval " = getmsg(int " fd ", struct strbuf *" ctlptr ", struct strbuf *" dataptr ", int *" flagsp );.SH DESCRIPTION.PP.B getmsgreads a STREAMS message from the read queue of a stream head into thecaller supplied buffers.  The read messages will contain a control part or adata part or both.  The data and control parts of the message are handledseparately by.BR getmsg() ..PPThe meaning and interpretation of the contents of the control part and datapart are specific to the STREAMS module to which the stream head is attached.The semantics of these contents forms a necessary part of the STREAMS moduledocumentation..PPThe arguments to.B getmsg()are interpreted as follows:.PP.I fdspecifies a file descriptor referencing an open stream..PP.I ctlptra pointer to a.B strbufstructure which describes the area used to store the control part of thereceived message..PP.I datptra pointer to a.B strbufstructure which describes the area used to store the data part of thereceived message..PPThe.B strbufstructure contains the following members:.sp.nf\fC\s-1\struct strbuf {    int maxlen;         /* maximum buffer length */    int len;            /* length of data */    char *buf;          /* ptr to buffer */};\s+1\fR.fi.TP 12.I maxlenspecifies the maximum number of bytes that the buffer pointed to by.I bufcan hold.When 0 is specified,.I maxlenrequests that only zero-length message be retrieved.When -1 is specified,.I maxlenrequests that the corresponding control or data part not be retrieved.When set to a positive value,.I maxlenrequests that at maximum only.I maxlenbytes of the control or data part be retrieved..TP 12.I lenis a return value only.  See.BR "\*(lqRETURN VALUES\*(rq" ,below..TP 12.I bufpoints to the buffer into which the data or control information is to be placed..PPIf.IR ctlptr " or " datptris.BR NULL ,or the corresponding.I maxlenfield is set to -1, the control or data part of the message is notprocessed and is left on the stream head read queue..PP.I flagspshould point to an integer that indicates the type of messagethe user is able to receive and will return the type of message received..PPFor.BR getmsg() ,.I flagsppoints to an integer thatcan have one of the following values:.TP 12.B 0requests retrieval of the first available message on the streamhead read queue regardless of message priority;.TP 12.B RS_HIPRIrequests retrieval of the first high priority message on the streamhead read queue, and that low priority messages not be processed..PPIf the stream head is set for non-blocking operation and no message of thespecified type and priority band is available to be read,.B getmsg()will fail and set.I errnoto.RB [ EAGAIN "] or [" EWOULDBLOCK ].If the stream head is set for blocking operation,.B getmsg()will block until a message of the specified type and priority band becomesavailble on the stream head read queue, or the call is interrupted by asignal.If the call is interrupted by a signal in this fashion,.B getmsg()will fail and set.I errnoto.BR EINTR ..\".PPIf a hangup occurs on the stream from which messages are to be retrieved,\fBgetmsg\fR continues to operate normally, as described above, until thestream head read queue is empty.  Thereafter, it returns 0 in the \fIlen\fRfield of \fIctlptr\fR and \fIdataptr\fR..SH "RETURN VALUES".PPUpon failure,.B getmsg()will return -1 and set.I errnoas described under.BR "\*(lqERRORS\*(rq" ,below..PPUpon success,.B getmsg()will return a non-negative value with any of the following flags set:.TP 12.B MORECTLindicates that more control information belonging to the same message iswaiting to be retrieved from the stream head read queue with a subsequent.B getmsg()operation..TP 12.B MOREDATAindicates that more data belonging to the same message is waiting to beretrieved from the stream head read queue with a subsequent.B getmsg()operation..B 0indicates that the entire message was received successfully..PP.B getmsg()with the appropriate arguments will retrieve a higher priority message beforethe remainder of a partially retreived lower priority message is retrieved..PPUpon success,.B getmsg()will also alter the.I lenvalues in the.B strbufstructures pointed to by.IR ctlbuf " and " datbufand the integer value pointed to by.IR flagp ,as follows:The.I maxlenmember is not altered on return.If the.IR ctlptr " or " datptra not.BR NULL ,and.I maxlenis not -1,the existence and length of the retrieved message is returned in the.I lenmember.If there is no control or data part retrieved, the.I lenmember of the corresponding.B strbufstructure is set to -1..PPIf the control or data part retrieved is of zero-length, the control or datapart is removed from the stream head read queue and the returned.I lenis set to 0.If.I maxlenis greater than or equal to 0 and the number of bytes in the control ordata part is greater than.IR maxlen ,only.I maxlenbytes are retrieved and the remaining bytes of the corresponding part are lefton the stream head read queue.  In the.IR retval ,the corresponding more flag.BR "" ( MORECTL " or " MOREDATA )is set.The.I bufmember is not altered on return..PPThe integer pointed to by.I flagspwill contain one of the following values:.TP 12.BR 0,the retrieved message is not a high priority message;.TP 12.BR RS_HIPRI,the retrived message is a high priority message..SH ERRORS.PPUpon failure,.B getmsg()willreturn -1 and set.I errnoas follows:.TP 12.RB [ EISDIR ].I fdrefers to a directory..TP 12.RB [ EBADF ].I fdis not a valid file descriptor or is not open for reading..TP 12.RB [ EFAULT ]A specified address is outside the user's accessible address space.Specified addresses include,.IR ctlptr ", " datptr ", " flagsp ,and the.I buffields of the.B strbufstructure pointed to by.IR cttlptr " and " datptr ..TP 12.RB [ ENODEV ].I fdrefers to a device that does not support the.B getmsg()system call..TP 12.RB [ ENOSTR ].I fdrefers to a device that has no stream associated with it..TP 12.RB [ EIO ]I/O error, or,.I fdrefers to a stream that is open but is in the process of closing..\".TP 12.\".RB [ EPERM ].\".I fd.\"points to a dynamic device and read permission on the device is denied..\".\".\".TP 12.RB [ EINVAL ].I fdis linked under a multiplexing driver; or,.B getmsg()is not supported; or, the flags pointed to by.I flagspwere invalid for.BR getmsg() ..TP 12.RB [ EAGAIN "], [" EWOULDBLOCK ]The stream head is set for non-blocking operation and.B getmsg()would block: that is, no message of the requested type and priority band isavailable to be read..TP 12.RB [ EINTR ]A signal was caught, or an.B M_SIGmessage processed, before the call to.B getmsg()could return any data..TP 12.RB [ ENOSTR ].I fdhas no stream associated with the file descriptor..TP 12.RB [ EBADMSG ]The message at the head of the queue is of an invalid message type (validmessage types include:.BR M_DATA ", " M_PROTO " and " M_PCPROTO );or, the message at head of the of the queue is not of the requested typeas specified by.IR flagsp ..PPOther errors may be returned by.BR getmsg() .If the STREAMS module sends a.B M_ERRORmessage to the stream head, the error returned on all subsequent readoperations, including.BR getmsg() ,is specified in the.B M_ERRORmessage by the STREAMS module.Which errors are returned under which conditions form part of thenecessary documentation of the STREAMS module..SH CAVEATS.PP.B LiS.[LiS.]could handle concurrent readers better.  Linux sockets code blocks concurrentreaders while a partial reader is installed against a socket.  When partialreads are performed for messages using.BR getmsg() ..B LiS.[LiS.]should install the partial reader and block all other readers from completingthe partial read until the partial reader completes the read or the partialreader closes the stream.  This would at least keep multiple threads ofexecution from interferring with partial reads..SH NOTES.PP.B LiS.[LiS.]implements.B getmsg()as a call to.B getpmsg()with a.B NULL.I bandppointer..SH BUGS.PP.B LiS.[LiS.]incorrectly returns.RB [ EINVAL ]instead of.RB [ EIO ]when the internal head queue pointer points to a structure that is not a queuestructure, or is mangled..PP.B LiS.[LiS.]incorreclty returns.RB [ EINVAL ]instead of.RB [ EIO ]when.I q->q_firstyeilds a.BR "" non- NULLmessage pointer, but.B getq()later cannot retrieve a message..PP.B LiS.[LiS.]does not return.RB [ EIO ]when.B getmsg()is called on a closing stream..PP.B LiS.[LiS.]incorrectly returns.RB [ EAGAIN "] or [" EWOULDBLOCK ]instead of.RB [ EINTR ]when an.B M_SIGmessage causes a signal that interrupts the call to.B getmsg()before any data is read..PP.B LiS.[LiS.]incorrectly returns.RB [ ENODEV ]instead of.RB [ ENOSTR ]when there is no stream associated with.IR fd ..PP.B LiS.[LiS.]incorrectly returns.RB [ EINVAL ]instead of.RB [ ENODEV ]when.I fdrefers to a device that does not support the.B getmsg()system call..SH "SEE ALSO".PP.BR intro (2),.BR poll (2),.BR putmsg (2),.BR read (2),.BR write (2),.BR streamio (2)..SH VERSIONS.PPThis manpage was written for.B LiS\c..[LiS.].PP.B getmsg()first appeared in SVR 3..[svr3.].\".\".XX.[magic.].[svr42.].[svr4.].[svr3.].[svid.].[xns.].[xbd5.].[$LIST$.].TI

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -