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

Linux»·¾³ÏµÄSocket±à³Ì

Linux»·¾³ÏµÄSocket±à³Ì
ʲôÊÇSocket
¡¡¡¡Socket½Ó¿ÚÊÇTCP/IPÍøÂçµÄAPI£¬Socket½Ó¿Ú¶¨ÒåÁËÐí¶àº¯Êý»òÀý³Ì£¬³ÌÐòÔ±¿ÉÒÔÓÃËüÃÇÀ´¿ª·¢TCP/IPÍøÂçÉϵÄÓ¦ÓóÌÐò¡£ÒªÑ§InternetÉϵÄTCP/IPÍøÂç±à³Ì£¬±ØÐëÀí½âSocket½Ó¿Ú¡£
¡¡¡¡Socket½Ó¿ÚÉè¼ÆÕß×îÏÈÊǽ«½Ó¿Ú·ÅÔÚUnix²Ù×÷ϵͳÀïÃæµÄ¡£Èç¹ûÁ˽âUnixϵͳµÄÊäÈëºÍÊä³öµÄ»°£¬¾ÍºÜÈÝÒ×Á˽âSocketÁË¡£ÍøÂçµÄSocketÊý¾Ý´«ÊäÊÇÒ»ÖÖÌØÊâµÄI/O£¬SocketÒ²ÊÇÒ»ÖÖÎļþÃèÊö·û¡£SocketÒ²¾ßÓÐÒ»¸öÀàËÆÓÚ´ò¿ªÎļþµÄº¯Êýµ÷ÓÃSocket()£¬¸Ãº¯Êý·µ»ØÒ»¸öÕûÐ͵ÄSocketÃèÊö·û£¬ËæºóµÄÁ¬½Ó½¨Á¢¡¢Êý¾Ý´«ÊäµÈ²Ù×÷¶¼ÊÇͨ¹ý¸ÃSocketʵÏֵġ£³£ÓõÄSocketÀàÐÍÓÐÁ½ÖÖ£ºÁ÷ʽSocket£¨SOCK_STREAM£©ºÍÊý¾Ý±¨Ê½Socket£¨SOCK_DGRAM£©¡£Á÷ʽÊÇÒ»ÖÖÃæÏòÁ¬½ÓµÄSocket£¬Õë¶ÔÓÚÃæÏòÁ¬½ÓµÄTCP·þÎñÓ¦Óã»Êý¾Ý±¨Ê½SocketÊÇÒ»ÖÖÎÞÁ¬½ÓµÄSocket£¬¶ÔÓ¦ÓÚÎÞÁ¬½ÓµÄUDP·þÎñÓ¦Óá£
Socket½¨Á¢
¡¡¡¡ÎªÁ˽¨Á¢Socket£¬³ÌÐò¿ÉÒÔµ÷ÓÃSocketº¯Êý£¬¸Ãº¯Êý·µ»ØÒ»¸öÀàËÆÓÚÎļþÃèÊö·ûµÄ¾ä±ú¡£socketº¯ÊýÔ­ÐÍΪ£º
¡¡¡¡int socket(int domain, int type, int protocol);
¡¡¡¡domainÖ¸Ã÷ËùʹÓõÄЭÒé×壬ͨ³£ÎªPF_INET£¬±íʾ»¥ÁªÍøЭÒé×壨TCP/IPЭÒé×壩£»type²ÎÊýÖ¸¶¨socketµÄÀàÐÍ£ºSOCK_STREAM »òSOCK_DGRAM£¬Socket½Ó¿Ú»¹¶¨ÒåÁËԭʼSocket£¨SOCK_RAW£©£¬ÔÊÐí³ÌÐòʹÓõͲãЭÒ飻protocolͨ³£¸³Öµ"0"¡£Socket()µ÷Ó÷µ»ØÒ»¸öÕûÐÍsocketÃèÊö·û£¬Äã¿ÉÒÔÔÚºóÃæµÄµ÷ÓÃʹÓÃËü¡£
¡¡¡¡SocketÃèÊö·ûÊÇÒ»¸öÖ¸ÏòÄÚ²¿Êý¾Ý½á¹¹µÄÖ¸Õ룬ËüÖ¸ÏòÃèÊö·û±íÈë¿Ú¡£µ÷ÓÃSocketº¯Êýʱ£¬socketÖ´ÐÐÌ彫½¨Á¢Ò»¸öSocket£¬Êµ¼ÊÉÏ"½¨Á¢Ò»¸öSocket"Òâζ×ÅΪһ¸öSocketÊý¾Ý½á¹¹·ÖÅä´æ´¢¿Õ¼ä¡£SocketÖ´ÐÐÌåΪÄã¹ÜÀíÃèÊö·û±í¡£
¡¡¡¡Á½¸öÍøÂç³ÌÐòÖ®¼äµÄÒ»¸öÍøÂçÁ¬½Ó°üÀ¨ÎåÖÖÐÅÏ¢£ºÍ¨ÐÅЭÒé¡¢±¾µØЭÒéµØÖ·¡¢±¾µØÖ÷»ú¶Ë¿Ú¡¢Ô¶¶ËÖ÷»úµØÖ·ºÍÔ¶¶ËЭÒé¶Ë¿Ú¡£SocketÊý¾Ý½á¹¹Öаüº¬ÕâÎåÖÖÐÅÏ¢¡£
SocketÅäÖÃ
¡¡¡¡Í¨¹ýsocketµ÷Ó÷µ»ØÒ»¸ösocketÃèÊö·ûºó£¬ÔÚʹÓÃsocket½øÐÐÍøÂç´«ÊäÒÔÇ°£¬±ØÐëÅäÖøÃsocket¡£ÃæÏòÁ¬½ÓµÄsocket¿Í»§¶Ëͨ¹ýµ÷ÓÃConnectº¯ÊýÔÚsocketÊý¾Ý½á¹¹Öб£´æ±¾µØºÍÔ¶¶ËÐÅÏ¢¡£ÎÞÁ¬½ÓsocketµÄ¿Í»§¶ËºÍ·þÎñ¶ËÒÔ¼°ÃæÏòÁ¬½ÓsocketµÄ·þÎñ¶Ëͨ¹ýµ÷ÓÃbindº¯ÊýÀ´ÅäÖñ¾µØÐÅÏ¢¡£
Bindº¯Êý½«socketÓë±¾»úÉϵÄÒ»¸ö¶Ë¿ÚÏà¹ØÁª£¬ËæºóÄã¾Í¿ÉÒÔÔڸö˿ڼàÌý·þÎñÇëÇó¡£Bindº¯ÊýÔ­ÐÍΪ£º
¡¡¡¡int bind(int sockfd,struct sockaddr *my_addr, int addrlen);
¡¡¡¡SockfdÊǵ÷ÓÃsocketº¯Êý·µ»ØµÄs


Ïà¹ØÎĵµ£º

linuxÇý¶¯¿ª·¢Ñ§Ï°±Ê¼Ç£¨¶þ£©

                    scull×Ö·ûÇý¶¯Ñ§Ï°±Ê¼Ç
Ŀ¼
1 scullÇý¶¯¼ò½é
2 Ö÷´Î±àºÅ
3 scullÔ´Âë·ÖÎö
-------------------------
|  1 scullÇý¶¯¼ò½é      |
-------------------------
  scullÊÇÒ»¸ö× ......

linuxÇý¶¯¿ª·¢Ñ§Ï°±Ê¼Ç£¨¶þ£©

                scull µÄMakefile
Makefile½Å±¾ÈçÏÂËùʾ¡£
--------------------------------------------------------------------------------
KERNEL_MAKE := -C /home/zhoumin/hi3511/Hi3511_VSSDK_V1.1.2.1/pub/kbuild-LESS_REL
PWD := $(shell pwd ......

ÉîÈëdz³ö LinuxÉ豸Çý¶¯×èÈûÓë·Ç×èÈû (select poll)


×èÈû²Ù×÷ÊÇÖ¸£¬ÔÚÖ´ÐÐÉ豸²Ù×÷ʱ£¬Èô²»ÄÜ»ñµÃ×ÊÔ´£¬Ôò½ø³Ì¹ÒÆðÖ±µ½Âú×ã¿É²Ù×÷µÄÌõ¼þÔÙ½øÐвÙ×÷¡£·Ç×èÈû²Ù×÷µÄ½ø³ÌÔÚ²»ÄܽøÐÐÉ豸²Ù×÷ʱ£¬²¢²»¹ÒÆð¡£±»¹ÒÆðµÄ½ø³Ì½øÈësleep״̬£¬±»´Óµ÷¶ÈÆ÷µÄÔËÐжÓÁÐÒÆ×ߣ¬Ö±µ½µÈ´ýµÄÌõ¼þ±»Âú×ã¡£
ÔÚLinuxÇý¶¯³ÌÐòÖУ¬ÎÒÃÇ¿ÉÒÔʹÓõȴý¶ÓÁУ¨wait queue£©À´ÊµÏÖ×èÈû²Ù×÷¡£wait queueºÜÔ ......

ÔÚLinuxÉϽ»²æ±àÒëpppd 2.4.4

ÔÚLinuxÉϽ»²æ±àÒëpppd 2.4.4
1. ÏÂÔØpppd 2.4.4µÄÔ´´úÂë
ftp://ftp.samba.org/pub/ppp/
2. Ö±½Ó±àÒë
#./configure
#make clean
#make
3. ½»²æ±àÒë
ÐÞ¸Ä./pppd-2.4.4/pppd/Makefile, ×¢ÊÍÁ½ÐУº
#wenxy comment #LIBS    += -lpcap
#wenxy comment #CFLAGS  += -DPPP_FILTER
cross compile ......

linuxÏ°²×°tomcat

ÔÚÕâ֮ǰjdkÒѾ­°²×°OK
1.°Ñtomcat´«µ½linux·þÎñÆ÷ÉÏ
 2.gunzip tomcat-6.0.20.tar.gz
 3.tar -zxvf tomcat-6.0.20.tar
 4.µÃµ½TomcatµÄËùÓÐÎļþ.È»ºó°ÑËü¿½±´µ½ÄãÒª°²×°µÄλÖã¬Èç/usr/local/tomcat-6.0.20/
 5.ÔÚ/etc/profileÎļþÖмÓÈëÈçÏÂÁ½ÐÐ

    export JAVA_HOME=/usr ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ