본문 바로가기
Server | Network

AIX 작업관련 UNIX/LINUX Development Documentation

by 두루물 2010. 11. 1.
UNIX / LINUX Windows All In One Integrated Environment

http://www.mkssoftware.com/docs


임베디드 리눅스 시스템 포럼

http://forum.falinux.com

국내 오픈소스 사용자와 개발자의 커뮤니티그룹의 대명사
http://kldp.org


AIX APPC 작업준비
금ㅇ원,경ㅇ청 작업관련 추가요청 작업 관련 다음의 기술사항을 적용하기로 한다.
mtype을 이용하여 호스트에 내부 경보발령용 요청 메세지를 전달하고,외부기관에서 오는것과
구별하여 응답전송을 보내지 않도록 수정할 일이 생겼다.

로컬 경보발령기에서 보내는 TCP데이타를 잘 선별하여 요청메시지큐에 집어넣을때,
/* queue messge */
typedef struct {
 long msgtyp;           /* message type   */
 char msgbuf[MAXDATSZ]; /* message buffer */
} QUEMSG_T;

msgtyp에 적절한 특수값을 지정하고,이값은 호스트로 전달하되 호스트의 응답은,Client 요청자
의 응답 메세지큐로 보내지 아니하도록 하고 그자리서 Drop 시키도록 구성하여,리얼머신의 업무와
구분지어 로컬 테스트용 경보를 발령할 수 있도록 Maintain 하게 수정하여 기존 시스템에 별다른
영향없이 구현하도록 기술지원 하기로 한다.

이런 코딩이전의 충분한 기술적 검토 사항은 아래와 같은 레퍼런스로 부터 출발한다.

http://www.mkssoftware.com/docs/man3/msgsnd.3.asp

SYNOPSIS

#include <sys/msg.h>

int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);


DESCRIPTION

The msgsnd() function sends a message to the queue associated with message queue identifier msqid.

If the call completes successfully, the following actions are taken with respect to the data structure (msqid_ds) associated with msqid:

  • msg_qnum is incremented by 1.
  • msg_lspid is set to the process ID of the calling process.
  • msg_stime is set to the current time.

The argument msgp must point to a user-defined buffer that must contain first a field of type long int that specifies the type of the message, and then a data portion that holds the data bytes of the message. The following structure is an example of how a user-defined buffer might be declared:

struct mymsg {
	long int mtype;
	char mtext[1];
}

The structure member mtype is the message type, and the structure member mtext contains any text of length msgsz bytes. The argument msgsz can range from 0 to a system-imposed maximum.


PARAMETERS

msqid 

Is a unique positive integer, created by msgget(), that identifies a message queue and its associated data structure.

msgp 

Points to a user-defined buffer.

msgsz 

Is the length of the message to be sent.

msgflg 

Specifies the action to be taken if one or more of the following are true:

  • The number of bytes already on the queue is equal to msg_qbytes from the msqid_ds data structure.
  • The total number of messages on all queues system-wide is equal to the system-imposed limit.

If (msgflg & IPC_NOWAIT) is non-zero, the message is not sent and the calling process returns immediately. If (msgflg & IPC_NOWAIT) is zero, the calling process suspends execution until one of the following occurs:

  • The condition responsible for the suspension no longer exists, in which case the message is sent.
  • msqid is removed from the system. When this occurs, errno is set to EIDRM, and -1 is returned.
  • The calling process receives a signal that is to be caught. In this case, the message is not sent and the calling process resumes execution as appropriate for the signal.

RETURN VALUES

If successful, msgsnd() returns a value of zero. On failure, msgsnd() returns a value of -1 and sets errno to one of the following values:

EACCES 

Operation permission is denied to the calling process.

EFAULT 

msgp is an invalid pointer.

EIDRM 

msqid was removed.

EINTR 

A signal interrupted the call.

EINVAL 

msgsz is less than 0 or greater than the system-imposed limit.

msqid is not a valid message queue identifier.

mtype is less than 1.

ENOMSG 

The message cannot be sent and (msgflg & IPC_NOWAIT) is non-zero.