©®linuxÉçÇø©® °®ÐÄÔ®Öú ©® LinuxÈÏÖ¤©®ÏµÁÐ½Ì³Ì ©® Òµ½ç¶¯Ì¬©® Õ¾ÎñÐÂÎÅ ©® ¹«Ë¾ÕÐÆ¸©® ½¨ÒéÁôÑÔ ©® ÍøÖ·´óÈ« ©®LPIרÌâ©® CISCOרÌâ
ÉèΪÊ×Ò³
¼ÓÈëÊÕ²Ø
¹ÜÀíÍŶÓ
JSP  
JAVA  
PERL  
 ÄúµÄλÖãºÊ×Ò³ > article > Linux¿ª·¢Çø > Èí¼þ¿ª·¢ >
À¸Ä¿µ¼À¸
×ÊÁÏËÑË÷
ÈÈÃÅÎÄÕÂ
¡¤Linux Ï C ÓïÑÔ±à³Ì
¡¤LinuxϵÄͨÓÃÏ̳߳ش´½¨
¡¤C++×Ö·û´®×ª»»Æª
¡¤linux C ½ø³Ì²Ù×÷ƪ
¡¤linuxÉϵÄC/C++±àÒëÆ÷gcc/egcs
¡¤linux C ÎļþȨÏÞ¿ØÖÆÆª
¡¤GCCʹÓÃÊÖ²á
¡¤linux C ½Ó¿Ú´¦ÀíÆª
¡¤ÔÚRedhat LinuxÉϰ²×° GCC ±àÒë
¡¤GCCʹÓÃÖ¸ÄÏ
¡¤CÓïÑÔÔËËã·û
¡¤LinuxÏÂC¿ª·¢»·¾³µÄ¹¹³ÉºÍ°²×°
¡¤fopen()º¯ÊýµÄ²ÎÊý˵Ã÷
¡¤GCCʹÓÃÊÖ²áÓë³£ÓÃÃüÁî
¡¤Scheme ÓïÑÔ½éÉÜ
×îÐÂÎÄÕÂ
¡¤ÔÚUbuntu Linux 8.04ÉϹ¹½¨GCC
¡¤Linux²Ù×÷ϵͳÏÂSocket±à³ÌµØÖ·
¡¤½«VC³ÌÐòÒÆÖ²µ½LinuxϵͳµÄ¼¸µã
¡¤LinuxÏÂmalloc/freeÓënew/dele
¡¤LinuxÏÂÓÃGTKºÍsocketʵÏÖ¼òµ¥
¡¤Linux²Ù×÷ϵͳÏÂÈÃTomcatÆô¶¯ÔÚ
¡¤Linux²Ù×÷ϵͳÖÐÈçºÎ±àÒëC³ÌÐò
¡¤¼¸ÖÖ³£±»ÈËÃǺöÂÔµÄLinuxϵͳÏÂ
¡¤Eclipse±à³Ì¹¤¾ß ÔÚUbuntuϵÄ
¡¤Linux²Ù×÷ϵͳϵÄÍøÂçµØÖ·×ª»»
¡¤ÀÏÊÖ¾­Ñé̸£ºLinuxÇý¶¯³ÌÐò¿ª·¢
¡¤Linux²Ù×÷ϵͳ¶àÏß³Ìͬ²½Mutex
¡¤Linux²Ù×÷ϵͳÏÂC³ÌÐòÓïÑÔ¼òÒ×
¡¤Linuxϵͳƽ̨ϹØÓÚGCC±àÒë¼°
¡¤½â¾öLinuxϵͳϹܵÀ±»½ÓÊÜ·½¹Ø
Google
 
linux C ½Ó¿Ú´¦ÀíÆª
[ ×÷Õß:LinuxÁªÃËÊÕ¼¯  ¼ÓÈëʱ¼ä:2006-06-24 14:13:30  À´×Ô:LinuxÁªÃËÊÕ¼¯ ]
h>MyPLinuxÁªÃË
¶¨Ò庯Êý
void endprotoent(void);MyPLinuxÁªÃË
º¯Êý˵Ã÷
endprotoent()ÓÃÀ´¹Ø±ÕÓÉgetprotoent()´ò¿ªµÄÎļþ¡£MyPLinuxÁªÃË
·µ»ØÖµ
MyPLinuxÁªÃË
·¶Àý
²Î¿¼getprotoent()MyPLinuxÁªÃË
¡¡
MyPLinuxÁªÃË
MyPLinuxÁªÃË
MyPLinuxÁªÃË
endservent£¨½áÊøÍøÂç·þÎñÊý¾ÝµÄ¶ÁÈ¡£©
Ïà¹Øº¯Êý
getservent£¬getservbyname£¬getservbyport£¬setserventMyPLinuxÁªÃË
±íÍ·Îļþ
#include<netdb.h>MyPLinuxÁªÃË
¶¨Ò庯Êý
void endservent(void);MyPLinuxÁªÃË
º¯Êý˵Ã÷
endservent()ÓÃÀ´¹Ø±ÕÓÉgetservent()Ëù´ò¿ªµÄÎļþ¡£MyPLinuxÁªÃË
·µ»ØÖµ
MyPLinuxÁªÃË
·¶Àý
²Î¿¼getservent()¡£MyPLinuxÁªÃË
¡¡
MyPLinuxÁªÃË
MyPLinuxÁªÃË
MyPLinuxÁªÃË
getsockopt£¨È¡µÃsocket״̬£©
Ïà¹Øº¯Êý
setsockoptMyPLinuxÁªÃË
±íÍ·Îļþ
#include<sys/types.h>MyPLinuxÁªÃË
#include<sys/socket.h>MyPLinuxÁªÃË
¶¨Ò庯Êý
int getsockopt(int s,int level,int optname,void* optval,socklen_t* optlen);MyPLinuxÁªÃË
º¯Êý˵Ã÷
getsockopt()»á½«²ÎÊýsËùÖ¸¶¨µÄsocket״̬·µ»Ø¡£²ÎÊýoptname´ú±íÓûÈ¡µÃºÎÖÖÑ¡Ïî״̬£¬¶ø²ÎÊýoptvalÔòÖ¸ÏòÓû±£´æ½á¹ûµÄÄÚ´æµØÖ·£¬²ÎÊýoptlenÔòΪ¸Ã¿Õ¼äµÄ´óС¡£²ÎÊýlevel¡¢optnameÇë²Î¿¼setsockopt()¡£MyPLinuxÁªÃË
·µ»ØÖµ
³É¹¦Ôò·µ»Ø0£¬ÈôÓдíÎóÔò·µ»Ø-1£¬´íÎóÔ­Òò´æÓÚerrnoMyPLinuxÁªÃË
´íÎó´úÂë
EBADF ²ÎÊýs ²¢·ÇºÏ·¨µÄsocket´¦Àí´úÂëMyPLinuxÁªÃË
ENOTSOCK ²ÎÊýsΪһÎļþÃèÊö´Ê£¬·ÇsocketMyPLinuxÁªÃË
ENOPROTOOPT ²ÎÊýoptnameÖ¸¶¨µÄÑ¡Ïî²»ÕýÈ·MyPLinuxÁªÃË
EFAULT ²ÎÊýoptvalÖ¸ÕëÖ¸ÏòÎÞ·¨´æÈ¡µÄÄÚ´æ¿Õ¼äMyPLinuxÁªÃË
·¶Àý
#include<sys/types.h>MyPLinuxÁªÃË
#include<sys/socket.h>MyPLinuxÁªÃË
main()MyPLinuxÁªÃË
{MyPLinuxÁªÃË
int s,optval,optlen = sizeof(int);MyPLinuxÁªÃË
if((s = socket(AF_INET,SOCK_STREAM,0))<0) perror(¡°socket¡±);MyPLinuxÁªÃË
getsockopt(s,SOL_SOCKET,SO_TYPE,&optval,&optlen);MyPLinuxÁªÃË
printf(¡°optval = %dn¡±,optval);MyPLinuxÁªÃË
close(s);}MyPLinuxÁªÃË
Ö´ÐÐ
optval = 1 /*SOCK_STREAMµÄ¶¨ÒåÕýÊÇ´ËÖµ*/MyPLinuxÁªÃË
¡¡
MyPLinuxÁªÃË
MyPLinuxÁªÃË
MyPLinuxÁªÃË
htonl£¨½«32λÖ÷»ú×Ö·û˳Ðòת»»³ÉÍøÂç×Ö·û˳Ðò£©
Ïà¹Øº¯Êý
htons£¬ntohl£¬ntohsMyPLinuxÁªÃË
±íÍ·Îļþ
#include<netinet/in.h>MyPLinuxÁªÃË
¶¨Ò庯Êý
unsigned long int htonl(unsigned long int hostlong);MyPLinuxÁªÃË
º¯Êý˵Ã÷
htonl£¨£©ÓÃÀ´½«²ÎÊýÖ¸¶¨µÄ32λhostlong ת»»³ÉÍøÂç×Ö·û˳Ðò¡£MyPLinuxÁªÃË
·µ»ØÖµ
·µ»Ø¶ÔÓ¦µÄÍøÂç×Ö·û˳Ðò¡£MyPLinuxÁªÃË
·¶Àý
²Î¿¼getservbyport()»òconnect()¡£MyPLinuxÁªÃË
¡¡
MyPLinuxÁªÃË
MyPLinuxÁªÃË
MyPLinuxÁªÃË
htons£¨½«16λÖ÷»ú×Ö·û˳Ðòת»»³ÉÍøÂç×Ö·û˳Ðò£©
Ïà¹Øº¯Êý
htonl£¬ntohl£¬ntohsMyPLinuxÁªÃË
±íÍ·Îļþ
#include<netinet/in.h>MyPLinuxÁªÃË
¶¨Ò庯Êý
unsigned short int htons(unsigned short int hostshort);MyPLinuxÁªÃË
º¯Êý˵Ã÷
htons()ÓÃÀ´½«²ÎÊýÖ¸¶¨µÄ16λhostshortת»»³ÉÍøÂç×Ö·û˳Ðò¡£MyPLinuxÁªÃË
·µ»ØÖµ
·µ»Ø¶ÔÓ¦µÄÍøÂç×Ö·û˳Ðò¡£MyPLinuxÁªÃË
·¶Àý
²Î¿¼connect()¡£MyPLinuxÁªÃË
¡¡
MyPLinuxÁªÃË
MyPLinuxÁªÃË
MyPLinuxÁªÃË
inet_addr£¨½«ÍøÂçµØÖ·×ª³É¶þ½øÖƵÄÊý×Ö£©
Ïà¹Øº¯Êý
inet_aton£¬inet_ntoaMyPLinuxÁªÃË
±íÍ·Îļþ
#include<sys/socket.h>MyPLinuxÁªÃË
#include<netinet/in.h>MyPLinuxÁªÃË
#include<arpa/inet.h>MyPLinuxÁªÃË
¶¨Ò庯Êý
unsigned long int inet_addr(const char *cp);MyPLinuxÁªÃË
º¯Êý˵Ã÷
inet_addr()ÓÃÀ´½«²ÎÊýcpËùÖ¸µÄÍøÂçµØÖ·×Ö·û´®×ª»»³ÉÍøÂçËùʹÓõĶþ½øÖÆÊý×Ö¡£ÍøÂçµØÖ·×Ö·û´®ÊÇÒÔÊý×ֺ͵ã×é³ÉµÄ×Ö·û´®£¬ÀýÈç:¡°163.13.132.68¡±¡£MyPLinuxÁªÃË
·µ»ØÖµ
³É¹¦Ôò·µ»Ø¶ÔÓ¦µÄÍøÂç¶þ½øÖƵÄÊý×Ö£¬Ê§°Ü·µ»Ø-1¡ LinuxÁªÃËÊÕ¼¯ÕûÀí ,תÌùÇë±êÃ÷ԭʼÁ´½Ó,ÈçÓÐÈκÎÒÉÎÊ»¶Ó­À´±¾Õ¾LinuxÂÛ̳ÌÖÂÛ
·ÖÒ³£º1 [2] 3 4 5 6
¡¾ÆÀÂÛ¡¿¡¾¼ÓÈëÊղؼС¿¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿¡¾¹Ø±Õ¡¿
¡ù Ïà¹ØÁ´½Ó
ÎÞÏà¹ØÐÅÏ¢