示例#1
0
文件: fork.c 项目: ctos/bpi
int main( void )
{
    int i, n_queue;
    int s, r;
    mach_port_t destination;

    kern_return_t err;
    printf("in qlimit\n");

    err = mach_port_allocate( mach_task_self(), MACH_PORT_RIGHT_RECEIVE,&destination );

    if( err != KERN_SUCCESS )
    {
        perror( "Error : could not allocate any port\n" );
    }
    if (fork() == 0)
        send_integer( destination, 9999);

    else 
    {
   	 receive_integer( destination, &r );

  	  printf("The received integer is : %d\n", r );

    }
    mach_port_deallocate( mach_task_self(), destination );

    return(r);
}
示例#2
0
文件: PROTOCOL.C 项目: jeske/GTalk
void send_packet(char *buffer, int length, char packetno, char checksum_type)
{
    if (length == 128) send_short(SOH_CHR);
     else send_short(STX_CHR);
    send_short(packetno);
    send_short(~packetno);
    send_buffer(buffer,length);
    switch (checksum_type)
    {
      case CRC_8: send_short(calc_8bit_checksum(buffer,length));
                  break;
      case CRC_16: send_integer(calc_crc_checksum((unsigned char *)buffer,length));
                   break;
    }
   wait_for_xmit(tswitch,30);
};
示例#3
0
文件: send.c 项目: ctos/bpi
int main( void )
{
    int i, n_queue;
    int s, r;
    mach_port_t destination;
    kern_return_t err;

    err = mach_port_allocate( mach_task_self(), MACH_PORT_RIGHT_RECEIVE,&destination );
    mach_port_insert_right(mach_task_self(), destination, destination, MACH_MSG_TYPE_MAKE_SEND); 

    printf("THE PORT IS %d.\n", destination);
    send_integer( destination, 9999 );
    mach_msg_type_name_t desired;
    err = mach_port_extract_right(mach_task_self(), destination, MACH_MSG_TYPE_PORT_RECEIVE, &destination, &desired); 
    if (err)
    {
    	error(1, err, "in mach_port_extract");
    }
    while (1);
    mach_port_deallocate( mach_task_self(), destination );

    return(r);
}