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

Linux socket API ʹÓÃʵÀý

°´ÏÂÃæ²½ÖèÀ´×ö£¬¿ÉÒÔ¼òµ¥ÌåÑésocket APIµÄʹÓ᣾ßÌ庯ÊýµÄÒâÒ壬Çë²Î¿¼ÆäËû˵Ã÷Îĵµ¡£
ÏÂÃæµÄº¯ÊýÖ±½Ócopy, paste¾Í¿ÉÒÔÁË¡£
Step1. ´´½¨Server ³ÌÐò¡£
н¨Îļþsocket_s.c, ÄÚÈÝÈçÏ£º
-------------------------------------------
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define PORT 2323
#define SERVER_IP "192.168.1.101"
int main()
{
    int s, s2;
    struct sockaddr_in addr;
    struct sockaddr_in addr2;
    char buffer[256];
    int sin_size;
    if((s=socket(AF_INET, SOCK_STREAM, 0))<0)
    {
        printf("creat socket error!\n");
        perror("socket");
        exit(1);
    }
   
    bzero(&addr, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(PORT);
    addr.sin_addr.s_addr = inet_addr(SERVER_IP);
    bzero(&(addr.sin_zero), 8);
    if(bind(s, (struct sockaddr *)&addr, sizeof(struct sockaddr))==-1)
    {
        perror("bind socket error!");
        exit(1);
    }
    if(listen(s, 10) == -1)
    {
        perror("LISTEN");
        exit(1);
    }
    while(1)
    {
        sin_size = sizeof(struct sockaddr_in);
        printf("server is run\n");
       


Ïà¹ØÎĵµ£º

Linux iptableÎĵµ

×ÜÀÀ
ÓÃiptables -ADC À´Ö¸¶¨Á´µÄ¹æ
Ôò
£¬-AÌí¼Ó -Dɾ³ý -C ÐÞ¸Ä
iptables - [RI] chain rule num rule-specification[option]
ÓÃiptables - RI ͨ¹ý¹æÔòµÄ˳ÐòÖ¸¶¨
iptables -D chain rule num[option]
ɾ³ýÖ¸¶¨¹æÔò
iptables -[LFZ] [chain][option]
ÓÃiptables -LFZ Á´Ãû [Ñ¡Ïî]
iptables -[NX] chain
ÓÃ -NX ......

linuxÍøÂçÅäÖõÄÐÞ¸Ä

LINUX--ÐÞ¸ÄIPµØÖ·
A¡¢ÐÞ¸ÄipµØÖ·
¼´Ê±ÉúЧ:
# ifconfig eth0 192.168.0.20 netmask 255.255.255.0
Æô¶¯ÉúЧ:
ÐÞ¸Ä/etc/sysconfig/network-scripts/ifcfg-eth0
B¡¢ÐÞ¸Ädefault gateway
¼´Ê±ÉúЧ:
# route add default gw 192.168.0.254
Æô¶¯ÉúЧ:
ÐÞ¸Ä/etc/sysconfig/network-scripts/ifcfg-eth0
C¡¢ÐÞ¸Ädns
ÐÞ ......

LinuxÈñ½ÝÉÏÍø,°²×°¹ý³Ì£º

ÏÂÔØÈñ½ÝÉÏÍø°ü,½âѹ,ÓÐĿ¼: libpcap.so.0.6.2, libstdc++.so.5,compat-libstdc%2B%2B-33_3.2.3-48_i386.deb,xrgsu
1½øÈëruijieĿ¼
sudo cd ./ruijie(½«¸ÃÎļþ¼Ð·ÅÔÚµ±Ç°Óû§Ä¿Â¼ÏÂ)
2¸´ÖÆÎļþ
sudo cp xrgsu /bin
sudo cp libpcap.so.0.6.2 /usr/lib
sudo cp libstdc++.so.5 /usr/lib
find /usr/lib -name " ......

LINUX ϶¯Ì¬£¬¾²Ì¬Á´½Ó¿âʵս

¶ÔÓÚ¶¯Ì¬Á´½Ó¿âºÍ¾²Ì¬Á´½Ó¿âµÄ¸ÅÄîÒÔ¼°Á´½Ó·½Ê½²»ÔÙÀÛ׸¡£Ö±½Ó¿ªÊ¼ÉÏ´úÂëºÍ½øÐбàÒë¡£-__-||¡£
´úÂëºÜ¼òµ¥£¬ºáÊú¾ÍÈý¸öµ±¼ÒµÄ¡£
¿âÍ·Îļþcorey.hpp:
#ifndef LIBRARY_H
#define LIBRARY_H
void add(int,int,int*);
#endif
¿âʵÏÖÎļþcorey.cpp
#include "corey.hpp"
void add(int a,int b,int *c){
int total=a ......

¹ØÓÚLinuxÄÚºËѧϰµÄÎóÇøÒÔ¼°Ïà¹ØÊé¼®½éÉÜ

¹ØÓÚLinuxÄÚºËѧϰµÄÎóÇøÒÔ¼°Ïà¹ØÊé¼®½éÉÜ
·¢ ²¼ ʱ ¼ä :
2008-11-19   
À´ Ô´ :
À´×ÔÍøÂç   
×÷ Õß :
ÄäÃû
  ä¯ ÀÀ :
1053


д¸øLinuxÄÚºËÐÂÊÖ-¹ØÓÚLinuxÄÚºËѧϰµÄÎóÇø
¡¡¡¡ÏÈ˵¾äÕý¾­µÄ£ºÆäʵÎÒû×ʸñдÕâƪÎÄÕ£¬ÒòΪ×Ô¼ºÒ²¾ÍÒ»Á½¸öÔÂÒÔÀ´²Å¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ