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¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ñµÃÌ×½Ó×Ö´íÎó¡¡¡¡¡¡¡¡¡
Ïà¹ØÎĵµ£º
¡¾×ª¡¿http://www.linuxsir.org/main/?q=node/241
1.°²×°»·¾³
²Ù×÷ϵͳ£ºRed Hat Linux Enterprise AS 4.0
Êý¾Ý¿â£ºMySQL 5.0.24
Web·þÎñÆ÷£ºApache 2.2.3
½Å±¾ÓïÑÔ£ºPHP 5.1.6
2.°²×°MySQL 5.0.24
-------------ÏÂÔØÈí¼þ°ümysql-5.0.24.tar.gz£¬µØÖ·http://www.mysql.com-------------
# tar zvxf mysql-5.0.24.ta ......
Linux ¹²Ïí¿â±à³Ì
×÷ÕߣºÖÕÄÏ <li.zhongnan@hotmail.com
>
1¡¢½éÉÜ
¶¯Ì¬¿âÊdzÌÐòÉè¼Æ³£Óõļ¼Êõ£¬²ÉÓö¯Ì¬¿â¿ÉÒÔÓÐЧµÄ¼õÉÙ³ÌÐò´óС£¬½ÚÊ¡¿Õ¼ä£¬Ìá¸ßЧÂÊ£¬Ôö¼Ó³ÌÐòµÄ¿ÉÀ©Õ¹ÐÔ£¬±ãÓÚÄ£¿é»¯¹ÜÀí¡£ÔÚWindowsºÍ
Linux²Ù×÷ϵͳÖж¼Óж¯Ì¬¿âµÄ¸ÅÄî¡£Windows½«Æä³ÆΪ¶¯Ì¬Á´½Ó¿â£¨Dynamic Link
Library£¬ ......
»·¾³:
±»¹¥ÏݵÄLinuxÖ÷»ú(Äõ½rootȨÏÞ)-----Ä£ÄâΪÎÒÄÚÍøµÄһ̨Linux·þÎñÆ÷ 192.168.0.105
hackµÄ²Ù×÷Óûú-----ÎҵĵçÄÔ 192.168.1.101
·´µ¯µ½¹«ÍøµÄ·þÎñÆ÷-----ÎÒ×Ô¼ºµÄ¹«Íø·þÎñÆ÷ 61.160.2xx.xxx
Éø͸²âÊÔÓõÄwindows²âÊÔ»ú 192.168.1.109
¹¤¾ß:
packetr-static Linux쵀
htran.exe win ......
Linux¹ÜÀíÔ±ÃÇ£¬¸ÃË¢ÐÂÄÚºËÁË
LinuxÖ®¸¸ÀîÄÉ˹·ÍÐÎÖ×È(Linus Torvalds)Ô®Òý¡¶Ê¥¾¡·ÖеÄÒ»¾ä»°¼ÄÓïLinux°®ºÃÕߣº“Ò»ÍùÎÞÇ°£¬ÉúÉú²»Ï¢¡£”µ«ÊÇʵ¼ÊÉÏ£¬¸ü׼ȷµÄÀí½âÓ¦¸ÃÊÇ“Ò»ÍùÎÞÇ°£¬²âÊÔ²»Ö¹”¡£¶ø×îÐÂÐèÒªÎÒÃDzâÊԵľÍÊǽüÆÚ¸Õ·¢²¼µÄ2.6.34°æLinuxÄںˣ¬¸ÃÄں˰汾µÄ·¢²¼Ê±¼ä¾àÀë´ËÇ°Ò»¸ö°æ ......
Linux POSIX Shell »·¾³ÖÐÖ§³ÖÊäÈëÊä³öÖض¨Ïò£¬Ó÷ûºÅ"<"ºÍ">"À´±íʾ¡£ÃüÁîÐÎʽ¿ÉÒÔÓÃ%>file»òÕß%<contentÀ´±íʾ(ÆäÖÐ%±íʾÎļþÃèÊö·û£º0Ϊ±ê×¼ÊäÈëstdin£¬1Ϊ±ê×¼Êä³östdout¡¢2Ϊ±ê×¼´íÎóstderr).ϵͳĬÈÏ%ÖµÊÇ1£¬Ò²¾ÍÊÇ1>£¬¿ÉÒÔ¼òдΪ>£¬Ò²¾ÍÊÇ˵ĬÈÏΪ1>¡£stdoutµÄĬÈÏÊä³öµ½Öնˣ¬stderrµÄĬÈÏÊä ......