Linux FIFO´úÂëÎÊÌâ - Linux/UnixÉçÇø / ³ÌÐò¿ª·¢Çø
/*speak.c*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define FIFO_NAME "american_maid"
int main(void)
{
char s[300];
int num, fd;
mknod(FIFO_NAME, S_IFIFO | 0666, 0);
printf("waiting for readers...\n");
fd = open(FIFO_NAME, O_WRONLY);
printf("got a reader--type some stuff\n");
while (gets(s), !feof(stdin)) {
if ((num = write(fd, s, strlen(s))) == -1)
perror("write");
else
printf("speak: wrote %d bytes\n", num);
}
return 0;
}
/*tick.c*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define FIFO_NAME "american_maid"
int main(void)
{
char s[300];
int num, fd;
mknod(FIFO_NAME, S_IFIFO | 0666, 0);
printf("waiting for writers...\n");
fd = open(FIFO_NAME, O_RDONLY);
printf("got a writer\n");
do {
if ((num = read(fd, s, 300)) == -1)
perror("read");
else {
s[num] = '\0';
printf("tick: read %d bytes: \"%s\"\n&
Ïà¹ØÎÊ´ð£º
ÈçÌ⣬ÔÚWINDOWSµ×ϵÄCODE»á£¬µ«ÔÚLINUXϲ»ÖªµÀÈçºÎʵÏÖ£¬JSµÄ´úÂëÓ¦¸ÃÊDz»Ò»ÑùµÄ¡£ Çó½Ì¡£
·Ö²»¹»ÔÙ¼Ó¡£
http://topic.csdn.net/u/20100113/08/17ba1e71-4c33-43f6-91a5-0e031c86e5ed.html
linux ......
int dValue = pthread_mutex_lock(&g_ThreadMutex);
if (0 != dValue)
{
. pthread_mutex_unlock(&g_ThreadMutex);
. return pToDealing;
}
----------------ʧ°Üºó£¬ÔÙµ÷ÓúìÉ«²¿·Ö£¬»á²»»áµ¼Ö³ÌÐ ......
×î½üÏëÁ˽âÏÂÄÚÁª»ã±à£¬ÏëÒªÓÃÀ´²Ù×÷ÏÂÊý×éµÄʱºòÓöµ½Ð©À§ÄÑ¡£
ÎÒÁ˽⵽µÄһЩ·½·¨£º
C/C++ code:
int main()
{
//ÕâÖÖ·½·¨¿ÉÒÔµ¥¶À²Ù×÷Êý×éÖеÄÒ»¸ö
int a[10];
__asm__("movl $10, %0&quo ......
ÔÚlinuxÏ°²×°µÄeclipse£¬ÔÚeclispeÖа²×°ÁËsvn²å¼þ£¬ Èç¹ûÐ޸ĺÍɾ³ýsvnÃÜÂ룿
csdn²»ÊǺܶà¸ßÊÖô? »òÕßÓÐËÖªµÀwindowsϵÄC:\Documents and Settings\Administrator\Application DataÕâ¸öĿ¼¶ÔÓ¦µ½linuxÄĸöÄ¿ ......
ÎÒ×°µÄÊÇSUSELinux£¬Ö®Ç°°ÑIPÉèÖÃÕâЩÉèÖúú󣬲¢ÇÒÊÇNATÁ¬½Ó·½Ê½£¬ÎÒµÄLinux¾ÍÖ±½Ó¿ÉÒÔÉÏÍøÁË¡£
µ«ÊÇÎÒÃÇÀÏʦ¸øÎҸijÉÇŽӷ½Ê½ºó£¬¾Í²»ÄÜÉÏÍøÁË£¬ÎÒÔڸĻØNAT£¬»¹ÊDz»ÄÜ£¬Ï£ÍûÓÐÈË°ïæ¡£
»òÕßÌṩ¸ü¼ÓÏêϸ׼ȷ ......