Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÏÂgetsockopt/setsockopt º¯Êý˵Ã÷

¹¦ÄÜÃèÊö£º
        »ñÈ¡»òÕßÉèÖÃ
Óëij¸öÌ×½Ó×Ö¹ØÁªµÄÑ¡ ÏѡÏî¿ÉÄÜ´æÔÚÓÚ¶à²ãЭÒé
ÖУ¬ËüÃÇ×Ü»á³öÏÖÔÚ×îÉÏÃæµÄÌ×½Ó×ֲ㡣µ±²Ù×÷Ì×½Ó×ÖÑ¡Ïîʱ£¬Ñ¡ÏîλÓڵIJãºÍÑ¡ÏîµÄÃû³Æ±ØÐë¸ø³ö¡£ÎªÁ˲Ù×÷Ì×½Ó×Ö²ãµÄÑ¡ÏӦ¸Ã ½«²ãµÄÖµÖ¸¶¨ÎªSOL_SOCKET¡£ÎªÁ˲Ù×÷ÆäËü²ãµÄÑ¡Ï¿ØÖÆÑ¡ÏîµÄºÏÊÊЭÒéºÅ±ØÐë¸ø³ö¡£ÀýÈ磬ΪÁ˱íʾһ¸öÑ¡ÏîÓÉTCP
ЭÒé½âÎö£¬²ãÓ¦¸ÃÉ趨ΪЭÒé ºÅTCP¡£
Ó÷¨£º
#include <sys/types.h>
#include <sys/socket.h>
int getsockopt
(int sock, int level, int optname, void *optval, socklen_t *optlen);
int setsockopt
(int sock, int level, int optname, const void *optval, socklen_t optlen);
²ÎÊý£º  
sock£º½«Òª±»ÉèÖûòÕß»ñÈ¡Ñ¡ÏîµÄÌ×½Ó×Ö¡£
level£ºÑ¡ÏîËùÔÚµÄЭÒé²ã¡£
optname£ºÐèÒª·ÃÎʵÄÑ¡ÏîÃû¡£
optval£º¶ÔÓÚgetsockopt()£¬Ö¸Ïò·µ»ØÑ¡ÏîÖµµÄ»º³å¡£¶ÔÓÚsetsockopt()£¬Ö¸Ïò°üº¬ÐÂÑ¡ÏîÖµµÄ»º³å¡£
optlen£º¶ÔÓÚgetsockopt()£¬×÷ΪÈë¿Ú²ÎÊýʱ£¬Ñ¡ÏîÖµµÄ×î´ó³¤¶È¡£×÷Ϊ³ö¿Ú²ÎÊýʱ£¬Ñ¡ÏîÖµµÄʵ¼Ê³¤¶È¡£¶ÔÓÚsetsockopt()£¬ÏÖÑ¡ÏîµÄ³¤¶È¡£
·µ»Ø˵Ã÷£º  
³É¹¦Ö´ÐÐʱ£¬·µ»Ø0¡£Ê§°Ü·µ»Ø-1£¬errno±»ÉèΪÒÔϵÄij¸öÖµ  
EBADF£ºsock²»ÊÇÓÐЧµÄÎļþ
ÃèÊö´Ê
EFAULT£ºoptvalÖ¸ÏòµÄÄÚ´æ²¢·ÇÓÐЧµÄ½ø³Ì¿Õ¼ä
EINVAL£ºÔÚµ÷ÓÃsetsockopt()ʱ£¬optlenÎÞЧ
ENOPROTOOPT£ºÖ¸¶¨µÄЭÒé²ã²»ÄÜʶ±ðÑ¡Ïî
ENOTSOCK£ºsockÃèÊöµÄ²»ÊÇÌ×½Ó×Ö
²ÎÊýÏêϸ˵Ã÷£º
levelÖ¸¶¨¿ØÖÆÌ×½Ó×ֵIJã´Î.¿ÉÒÔÈ¡ÈýÖÖÖµ:
1)SOL_SOCKET:ͨÓÃÌ×½Ó×ÖÑ¡Ïî.
2)IPPROTO_IP:IPÑ¡Ïî.
3)IPPROTO_TCP:TCPÑ¡Ïî.¡¡
optnameÖ¸¶¨¿ØÖƵķ½Ê½(Ñ¡ÏîµÄÃû³Æ),ÎÒÃÇÏÂÃæÏêϸ½âÊÍ¡¡
optval»ñµÃ»òÕßÊÇÉèÖÃÌ×½Ó×ÖÑ¡Ïî.¸ù¾ÝÑ¡ÏîÃû³ÆµÄÊý¾Ý
ÀàÐͽøÐÐת»»¡¡
Ñ¡ÏîÃû³Æ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ËµÃ÷¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Êý¾ÝÀàÐÍ
========================================================================
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SOL_SOCKET
------------------------------------------------------------------------
SO_BROADCAST¡¡¡¡¡¡¡¡¡¡¡¡ÔÊÐí·¢Ë͹㲥Êý¾Ý¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int
SO_DEBUG¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÔÊÐíµ÷ÊÔ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int
SO_DONTROUTE¡¡¡¡¡¡¡¡¡¡¡¡²»²éÕÒ·ÓÉ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡int
SO_ERROR¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ñµÃÌ×½


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì (Æß) SDPЭÒé

Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖЭÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀЭÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......

[תÌû]LinuxÇý¶¯¿ª·¢Ñ§Ï°µÄһЩ±ØÒª²½Öè

 1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......

ÈçºÎʵÏÖLinuxÎı¾Ä£Ê½ÏÂ×Ô¶¯¹ÒÔعâÇý

mountÊÇÓÃÀ´¹ÒÔØÎļþϵͳµÄ£¬¿ÉÒÔÔÚÆô¶¯µÄʱºò¹ÒÔØÒ²¿ÉÒÔÔÚÆô¶¯ºó¹ÒÔØ¡£ÔÚÆô¶¯ºó¹ÒÔØ¿ÉÒÔʹÓÃmountÃüÁîʵÏÖ£¬ÒªÊµÏÖÆô¶¯Ê±×Ô¶¯¹ÒÔØÉ豸ÔòÐèÆô¶¯autofs·þÎñ¾ÍÌṩÕâÖÖ¹¦ÄÜ¡£¸Ã¹¦ÄܾÍÏñwindowsÖеĹâÇý×Ô¶¯´ò¿ª¹¦ÄÜ£¬Äܹ»¼°Ê±¹ÒÔض¯Ì¬¼ÓÔصÄÎļþϵͳ¡£ÃâÈ¥ÎÒÃÇÊÖ¶¯¹ÒÔÚÂé·³¡£ÒªÊµÏÖ¹âÇý£¬ÈíÅ̵ȵĶ¯Ì¬×Ô¶¯¹ÒÔØ£¬ÐèÒª½øÐÐÏà¹Øµ ......

ZZ: When Linux Runs Out of Memory (OOM killer)


When Linux Runs Out of Memory
http://linuxdevcenter.com/pub/a/linux/2006/11/30/linux-out-of-memory.html?page=1
Perhaps you rarely face it, but once you do, you surely know what's
wrong: lack of free memory, or Out of Memory (OOM). The results are
typical: you can no longer allocate more memory ......

dz̸LinuxµÄ¿ÉÖ´ÐÐÎļþ¸ñʽELF

 ÏÖ´úLinux²ÉÓÃELF×öΪÆä¿ÉÁ¬½ÓºÍ¿ÉÖ´ÐÐÎļþµÄ¸ñʽ£¬Òò´ËELF¸ñʽҲÏòÎÒÃÇ͸³öÁËÒ»µãLinuxºËÄÚµÄÇé¾°£¬¾ÍÏñϷ̨άĻÁôϵÄÒ»ÌõδÀ­Ñϵķ졣PCÊÀ½ç32ÈÔÊÇÖ÷Á÷£¬µ«64λµÄ½Å²½È´ÒÑÈç´ËµÄ±Æ½ü¡£±¾ÎÄ×ÅÖؽ²Êö32λELFµÄͬʱ¸½´øÁË64λµÄÐÅÏ¢£¬ÕâÁ½ÖÖ¸ñʽÈç´ËÀ×ͬ£¬ÒÔÖÂÓÚ³õ´Î½Ó´¥ELFµÄ¶ÁÕß²»±Ø¼æ¹Ë×óÓÒ¡£Èç¹ûÄã¶ÔWindows±È½ÏÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ