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¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ñµÃÌ×½Ó×Ö´íÎó¡¡¡¡¡¡¡¡¡
Ïà¹ØÎĵµ£º
ÓÉÓÚÁ½¸öϵͳÉ趨ʱ¼äʱÒÔÖ÷°åCMOSÄÚµÄʱ¼äΪÒÀ¾Ý£¬µ«È´Óв»Í¬µÄʱ¼ä¼ÆËã±ê×¼¡£ËùÒÔµ¼ÖÂÁËϵͳʱ¼äµÄ¾À·×ÎÊÌâ¡£
LinuxºÍÆ»¹û²Ù×÷ϵͳÒÔµ±Ç°Ö÷°åCMOSÄÚʱ¼ä×öΪ¸ñÁÖÍþÖαê׼ʱ¼ä£¬ÔÙ¸ù¾ÝϵͳÉèÖõÄʱÇøÀ´×îÖÕÈ·¶¨µ±Ç°ÏµÍ³Ê±¼ä£¨ÈçʱÇøÉèÖÃΪGMT+08:00±±¾©Ê±¼äʱÒÔ¼°µ±Ç°CMOSʱ¼äΪ03 ......
×î½üÒ»Ö±Ïë×°linux U5,һֱûÕÒµ½£¬½ñÌìÕÒµ½ÁË£¬·ÖÏí¸ø´ó¼Ò£¡£¡£¡
ftp://openware.byr.edu.cn/pub/os-images/Redhat/RHEL4u5/i386/RHEL4-U5-i386-AS-disc1.iso
ftp://openware.byr.edu.cn/pub/os-images/Redhat/RHEL4u5/i386/RHEL4-U5-i386-AS-disc2.iso
ftp://openware.byr.edu.cn/pub/os-images ......
ÐèÇó
£º
°Ñ88E6131½»»»Ð¾Æ¬µÄ
sdkÒÆÖ²µ½ÏÖÓÐǶÈëʽ
linuxϵͳÖУ¬Ê¹µÃÒÔºóÄÜͨ¹ýÉϲ㺯ÊýÔÚ¶Ô½»»»Ð¾Æ¬½øÐÐÅäÖòÙ×÷£¨Èç
lanÅäÖã©¡£
ÒÑÖªÌõ¼þ£º
*Óн»»»Ð¾Æ¬µÄÎĵµ
,sdkÔ´Âë
,Àý×Ó
,ÎÞÕë¶ÔÏÖÓÐϵͳµÄÖ±½Ó½â¾ö·½°¸
.
ʵÏÖ·½·¨¸ÅÊö£º
* ±àÒë ......
1.Windows Ï´ò¿ªvirtualBox £¬Æô¶¯ÐéÄâ»ú¡£ÔÚÐéÄâ»ú´°¿ÚÉÏÑ¡Ôñ É豸 ->·ÖÅäÊý¾Ý¿Õ¼ä
2.Ñ¡ÔñWindowsÏÂÄãÏëÒª¹²ÏíµÄÎļþ¼Ð ÈçH:share , Ìí¼Ó¹Ì¶¨Êý¾Ý·ÖÅä¿Õ¼ä ,·ÖÅä¸÷Ãû×ÖÈ磺VMshare
3.ÔÚÐéÄâ»úlinuxÖն˹ÒÆð¸Õ·ÖÅäµÄÊý¾Ý¿Õ¼ä£¬
sudo monut -t vboxsf VMshare /home/plus/share #ÆäÖÐ/home/plus/shareÊÇ ......