¹ØÓÚlinuxµÄ¶Áд²Ù×÷
½¨Á¢ÁËÁ¬½Ó,¾Í¿ÉÒÔ½øÐÐͨѶÁË,ÍùÎļþÃèÊö·ûÀï¶Áд,ºÍ¶ÁдÎļþÊÇÒ»ÑùµÄ.
дº¯Êý:
ssize_t write(int fd,(void *)buf,size_t nbytes)
½«bufÖеÄnbytesдÈëµ½fdÖÐ,³É¹¦Ê±·µ»ØËùдµÄ×Ö½ÚÊý,ʧ°Üʱ·µ»Ø-1,²¢Ð´Èëerrno±äÁ¿.
µ±ÎÒÃÇÏóÌ×½Ó×ÖдÊý¾Ýʱ,¿ÉÄÜ»áÓÐÁ½ÖÖÇé¿ö:
a.writeµÄ·µ»ØÖµ´óÓÚ0,±íʾдÁ˲¿·Ö»òÕßÊÇÈ«²¿µÄÊý¾Ý
b.·µ»ØµÄֵСÓÚ0,´Ëʱ³öÏÖÁË´íÎó.ÎÒÃÇÒª¸ù¾Ý´íÎóÀàÐÍÀ´´¦Àí
Èç¹û´íÎóΪEINTR±íʾÔÚдµÄʱºò³öÏÖÁËÖжϴíÎó.
Èç¹ûΪEPIPE±íʾÍøÂçÁ¬½Ó³öÏÖÁËÎÊÌâ(¶Ô·½ÒѾ¹Ø±ÕÁËÁ¬½Ó).
¶Áº¯Êý:
ssize_t read(int fd,(void *)buf,size_t nbytes)
´ÓfdÖжÁÄÚÈÝ,µ±¶Á³É¹¦Ê±,·µ»Ø¶ÁÈëµÄ×Ö½ÚÊý,·µ»ØÊÇ0,Ôð±íʾÒѾ¶ÁÈëµ½Îļþ½áÊøÁË,СÓÚ0±íʾ³öÏÖÁË´íÎó.
Êý¾Ý±¨µÄ·¢ËÍ:
int recvfrom(int sockfd,void *buf,int len,unsigned int flags,struct sockaddr *from,int *fromlen);
int sendto(int sockfd,const void *msg,int len,unsigned int flags,struct sockaddr *to,int tolen);
sockfd,buf,lenµÄÒâÒåºÍread,writeÒ»Ñù,·Ö±ð±íʾÌ×½Ó×ÖÃèÊö·û,·¢ËÍ»ò½ÓÊյĻº³åÇø¼°´óС.recvfrom¸ºÔð´Ósockfd½ÓÊÕÊý¾Ý,Èç¹ûfrom²»NULL,ÄÇôÔÚfromÀïÃæ´æ´¢ÁËÐÅÏ¢À´Ô´µÄÇé¿ö,Èç¹û¶ÔÐÅÏ¢µÄÀ´Ô´²»¸ÐÐËȤ,¿ÉÒÔ½«fromºÍfromlenÉèÖÃΪNULL.sendto¸ºÔðÏòto·¢ËÍÐÅÏ¢.´ËʱÔÚtoÀïÃæ´æ´¢ÁËÊÕÐÅÏ¢·½µÄÏêϸ×ÊÁÏ.
¸ß¼¶Ì×½Ó×Öº¯Êý:
int recv(int sockfd,void *buf,int len,int flags)
int send(int sockfd,void *buf,int len,int flags)
Ç°ÃæµÄÈý¸ö²ÎÊýºÍread()ºÍwrite()º¯ÊýÒ»ÑùµÄ,²ÎÊýflags¿ÉÒÔÊÇ0»òÕßÒÔÏÂÈκÎÒ»Ïî:
MSG_DONTROUTE:ÊÇsend()º¯ÊýʹÓõıêʶ,¸æËßIPÐÒé,Ä¿µÄÖ÷»úÔÚ±¾ÍøÂçÉÏÃæ,ûÓбØÒª²éÕÒ·Óɱí;
MSG_OOB:½ÓÊÜ»òÕß·¢Ë͸½´øÊý¾Ý;
MSG_PEEK:recv()º¯ÊýʹÓõIJÎÊý,±íʾֻ´Óϵͳ»º³åÇøÖжÁÈ¡Êý¾Ý,¶ø²»Çå³ýϵͳ»º³åµÄÄÚÈÝ,Ò»°ãÔÚ¶à¸ö½ø³Ì¶ÁдÊý¾ÝµÄʱºòʹÓÃ;
MSG_WAITALL:ÊÇrecv()º¯ÊýʹÓõIJÎÊý,±íʾµÈµ½ËùÓеÄÊý¾Ýµ½´ïºó²Å·µ»Ø.ʹÓÃÕâ¸ö²ÎÊýʱ,recv()º¯Êý»áÒ»Ö±×èÈû.
Ì×½Ó×ֵĹرÕ:
Ì×½Ó×ֵĹرÕÓÐÁ½¸öº¯Êý:
shutdown()ºÍclose()
int shutdown(int sockfd,int howto)
TCPÁ¬½ÓÊÇË«ÏòµÄ(ÊǿɶÁдµÄ),µ±ÎÒÃÇʹÓÃcloseʱ,»á°Ñ¶ÁдͨµÀ¶¼¹Ø±Õ,ÓÐʱºîÎÒÃÇÏ£ÍûÖ»¹Ø±ÕÒ»¸ö·½Ïò,Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃshutdown.Õë¶Ô²»Í¬µÄhowto,ϵͳ»Ø²ÉÈ¡²»Í¬µÄ¹Ø±Õ·½Ê½.
howto=0Õâ¸öʱºòϵͳ»á¹Ø±Õ¶ÁͨµÀ.µ«ÊÇ¿ÉÒÔ¼ÌÐøÍù½Ó×ÖÃèÊö·ûд.
howto=1¹Ø
ת×Ôhttp://blog.163.com/ericxia_gnikam/blog/static/969208792008102545614453/
ÔÚLinux kernelµÄÔ´´úÂëÖУ¬¾³£Äܼûµ½if(likely(x))»òif(unlikely(x))Ö®ÀàµÄÓ÷¨£¬ÆäÈ·Çк¬ÒåÐèҪ˵Ã÷һϣ¬ÒÔ±ã¸üºÃµÄÀí½âkernelµÄÔ´´úÂë¡£
likelyÓëunlikelyÕâÁ½¸öºêÔÚlinux/compiler.hÖеĶ¨ÒåÈçÏ£º
#define likely ......
¾¡¹ÜLinux¿ª·¢µÄÏà¹Ø¸ÚλºÜ¶à£¬µ«³¤ÆÚÒÔÀ´Linux¿ª·¢Ã»ÓÐͳһµÄ¿ª·¢Æ½Ì¨£¬´ó¶àÊýµÄ¿ª·¢Õ߶¼Ö±½ÓʹÓÃVI¡¢GCCµÈÃüÁîÐй¤¾ß£¬ÕâÑùÆäʵ²»ÀûÓÚ´óÐÍÏîÄ¿µÄ¿ª·¢¡£ 1.ÒÀÈ»ÊÇÊìϤµÄ¿ª·¢Á÷³Ì ÔÚLinux²Ù×÷ϵͳÖУ¬CÓïÑÔ³ÌÐòµÄ¿ª·¢ºÍÆäËû»·¾³ÀàËÆ£¬³ÌÐòÉú³ÉÖ÷Òª·Ö³É±àÒë¡¢»ã±à¡¢Á¬½ÓµÈ¼¸¸ö²½Öè¡£ ± ......
1. °²×°Ç°µÄ×¼±¸¹¤×÷
1.1 È·¶¨Ò»¸ö°²×°Ä¿Â¼£¬½¨Òé¸ÃĿ¼ÏÂÖÁÉÙÓÐ1¸öGµÄ¿Õ¼ä£¬¿ÉÒÔʹÓÃduÀ´²ì¿´´ÅÅÌ¿Õ¼äµÄʹÓÃÇé¿ö
1.2×¼±¸weblogic°²×°Èí¼þ£¬±ÈÈ磺platform815_linux32.bin£¬ÉÏ´«µ½linux°²×°Ä¿Â¼ÏÂ
1.3 ´´½¨Ò»¸öBEAÓû§×éÕʺÅ
groupadd -g GID groupname
˵Ã÷£ºGID´ú±í´´½¨×éµÄID£¬Ò»°ã´óÓÚ500
±ÈÈ磺groupadd -g 60 ......