Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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µÄÊÓƵͼÏñ²É¼¯Óë´«Êä

 
ÕªÒª:ÊÓƵͼÏñ²É¼¯¼°´¦Àí¼¼ÊõÔÚÔ¶³ÌÊÓƵ¼à¿ØºÍ¿ÉÊӵ绰ÖÐÓÐ׏㷺µÄÓ¦ÓÃÇ°¾°£¬Çý¶¯ÊÓƵ²É¼¯É豸ºÍ»ñÈ¡ÊÓƵÊý¾Ý²¢½øÐÐÏàÓ¦µÄ´¦Àí£¬ÊÇʵÏÖÕâЩӦÓõĻù´¡¡£Õë¶ÔÕâЩӦÓ㬹¹½¨ÁËÒ»¸ö»ùÓÚǶÈëʽ LinuxºÍ PXA270΢´¦ÀíÆ÷µÄÊÓƵ²É¼¯Óë´«Êäϵͳ£¬ÀûÓà Video4LinuxʵÏÖ USBÉãÏñÍ·ÊÓƵÊý¾Ý²É¼¯£¬²É¼¯µÄÊÓƵÊý¾Ý¾­ JPEGѹËõº ......

LinuxÏÂMemcache·þÎñÆ÷¶ËµÄ°²×°

×î½üÔÚÑо¿ÔõôÈÃDiscuz!È¥Ó¦ÓÃMemcacheÈ¥×öһЩÊÂÇ飬¼Ç¼ÏÂMemcache°²×°µÄ¹ý³Ì¡£
LinuxÏÂMemcache·þÎñÆ÷¶ËµÄ°²×°
·þÎñÆ÷¶ËÖ÷ÒªÊÇ°²×°memcache·þÎñÆ÷¶Ë£¬Ä¿Ç°µÄ×îа汾ÊÇ memcached-1.3.0 ¡£
ÏÂÔØ£ºhttp://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
ÁíÍ⣬MemcacheÓõ½ÁËlibeventÕâ¸ö¿âÓÃÓÚSocketµÄ´¦Àí£ ......

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ϽûÖ¹ÐÞ¸ÄDNS·þÎñÆ÷µØÖ·(DNS±»×Ô¶¯ÐÞ¸ÄÎÊÌâ)

´ó¼Ò¶¼ÖªµÀÐÞ¸ÄlinuxϵÄDNS¿ÉÒÔÖ±½ÓÐÞ¸Ä/etc/resolv.conf:
root@xuanfei-desktop:~#vim /etc/resolv.conf
nameserver ip //ÌîÉÏÄãµ±µØʹÓõÄ×î¿ìDNS·þÎñÆ÷IPµØÖ·
nameserver ip   
 
µ±È»Ò²¿ÉÒÔÖ±½ÓʹÓÃÍøÂç¹ÜÀíÆ÷Ð޸ġ£
µ«ÊÇÈç¹ûÄãËùÔÚ»ú¹¹»òÕß¹¤×÷µÄµØ·½±ØÐëÒªÇóÄãÓÃDHCP»ñµÃ×Ô¼º·Ç¹Ì¶¨¶¯Ì¬IP ......

LINUXϲ鿴Ӳ¼þÐÅÏ¢

¼¸¸öcpu
more /proc/cpuinfo |grep "physical id"|uniq|wc -l
ÿ¸öcpuÊǼ¸ºË£¨¼ÙÉècpuÅäÖÃÏàͬ£©
more /proc/cpuinfo |grep "physical id"|grep "0"|wc -l
cpuʹÓÃÂÊ
vmstat  
ÍƼöС¹¤¾ßnmon£¨aixºÍlinux¶¼ÓУ©
topºó°´Êý×Ö1,¶à¸öcpuµÄ»°»áÏÔʾ¶à¸ö
fdisk -l¿ÉÒÔ¿´µ½¶à¸öÎïÀíÓ²ÅÌ£¬×öÁËÓ²raidÖ»ÄÜ¿´µ½Ò»¸öӲŠ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ