Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ :

ÔÚLinuxÉÏ»ùÓÚÔ´µØÖ·Â·ÓÉʵÏÖµçÐÅÍøÍ¨Ë«Ïß

ÏëҪͨ¹ýÆÕͨµÄ¾²Ì¬²ßÂÔ·ÓÉÀ´ÊµÏÖµçÐÅÍøÍ¨Ë«Ïß»ù±¾ÉÏÊDz»¿ÉÄܵģ¬ÒòΪÄǽ«ÐèҪά»¤Ï൱´óµÄÒ»¸öIP¶ÎµÄÊý¾Ý¿â£¬¶øÇÒ»¹ÐèÒªËæÊ±¸üвÅÄܱ£Ö¤Ð§¹û¡£
ºóÀ´Ìýǰ±²ÃÇ˵£¬¿ÉÒÔ²ÉÓûùÓÚÔ´µØÖ·Â·Óɵķ½Ê½À´´¦Àí£¬ÈýøÀ´µÄÊý¾Ý£¬´ÓÄĸöIP½øÀ´¾Í´ÓÄĸöIP·µ»Ø¡£
ÏÂÃæ¾ÍÊÇÒ»¸öÔÚÉú²úÖеõ½ÁËʵ¼ÊÓ¦ÓõĽű¾£º
==============================================================
#!/bin/bash
##
## CNC_RULE AND CTC_RULE from /etc/iproute2/rt_tables
## echo 200 cnc >> /etc/iproute2/rt_tables
## echo 201 ctc >> /etc/iproute2/rt_tables
##
CTC_DEVICE="eth0"
CTC_RULE="ctc"
CTC_NETWORK="10.10.10.0"
CTC_GATEWAY="10.10.10.1"
CTC_IPADDR="10.10.10.2"
CNC_DEVICE="eth1"
CNC_RULE="cnc"
CNC_NETWORK="20.20.20.0"
CNC_GATEWAY="20.20.20.1"
CNC_IPADDR="20.20.20.2"
ACTION="add"
if [ $# -ne 0 ]; then
        if [ "$1" != "add" -a "$1" != "del" ]; then
                echo "error"
    &nbs ......

Socket±à³Ì£ºÓÉLinuxÏòWindowsÒÆÖ²ÎÊÌâ


ת×Ô£ºhttp://www.cic.tsinghua.edu.cn/jdx/book1/CHAPTER3.htm
 
ÔÚÔ´Îļþ¿ªÊ¼Ôö¼Ó#include <winsock.h>Óï¾ä¡£
µ÷ÓÃWSAStartup()º¯Êý³õʼ»¯Windows Sockets DLL£¬²¢ÔÚ½áÊøÊ±µ÷ÓÃWSACleanup()º¯Êý֪ͨWindows Sockets DLLÊÍ·Å×ÊÔ´¡£
½«Ì×½Ó×ÖµÄÀàÐÍΪint¸ÄΪSOCKET¡£
»ñÈ¡¡¢ÉèÖôíÎóÂ벻ҪʹÓÃÈ«¾Ö±äÁ¿errno, ½«Æä¸ÄΪWindows SocketsÍÆ¼öµÄWSAGetLastError()º¯ÊýºÍWSASetLastError()º¯Êý¡£
ʹÓÃclosesocket()º¯Êý´úÌæclose()º¯ÊýÀ´¹Ø±ÕÌ×½Ó×Ö£»Ê¹ÓÃioctlsocket()º¯Êý´úÌæioctl()º¯ÊýºÍfcntl()º¯ÊýʵÏÖ¶ÔÌ×½Ó×ÖģʽµÄ¿ØÖÆ¡£
getsockopt()º¯ÊýºÍsetsockopt()º¯ÊýÔÚBerkeley SocketsºÍWindows SocketsÖÐÌṩµÄÖ§³Ö²»Í¬£¬Ô´³ÌÐò¿ÉÄÜÒª×ö±ØÒªµÄÐ޸ġ£Ïê¼ûµÚÁùÕº¯ÊýµÄʹÓÃ˵Ã÷¡£
½«Ô´³ÌÐòÖжԽṹfd_setµÄÖ±½ÓÐ޸ĸÄΪͨ¹ýʹÓÃFD_XXXºêÀ´Ð޸ġ£
½«Ô´³ÌÐòÖдíÎóÂë¸ÄΪWindows SocketsÍÆ¼öµÄÒÔWSA´òÍ·µÄ³£Êý¶¨ÒåÖµ¡£
½«Windows SocketsÓ¦ÓóÌÐòµÄÖ¸Õë¶¼ÉèΪFARÀàÐÍ¡£
×îºÃ½«Ô´³ÌÐòÖеÄ×èÈûµ÷ÓøÄΪWindows SocketsÍÆ¼öʹÓõĻùÓÚÏûÏ¢µÄÒì²½²Ù×÷¡£
......

ѧϰlinux programming(1)


¡¾1. linux applications ÓÐÁ½ÖÖÐÎʽ¡¿
  i£©¿ÉÖ´ÐеÄÎļþ£º ¿ÉÓɼÆËã»úÖ±½ÓÔËÐУ¬Ï൱ÓÚwindowsµÄ.exeÎļþ
  ii£©Script: collections of instructions for another program. Ï൱ÓÚwindowsµÄ.bat .cmdÎļþ
 
¡¾2. PATH¡¿
ÔÚLinuxÖУ¬µ±ÊäÈë³ÌÐòÃû£¨ÈçFirefox£©Ê±£¬ÏµÍ³»áÔÚÃûΪPATHµÄShell±äÁ¿Ëù¸ø¶¨µÄһϵÁÐĿ¼ÖÐѰÕÒÊÇ·ñÓÐͬÃûµÄÎļþ¡£
  ²é¿´PATHµÄÖµ£¬ÔÚLinux£º $PATH »òÕß echo $PATH
                windows£º PATH
Linux¿ÉÖ´ÐÐÎļþλÖÃ˵Ã÷£º
/bin: binaries, programs used in booting the system
/usr/bin: user binaries, standard programs available to users
/usr/local/bin:  local binaries, programs specific to an installation
µ±ÒÔadministatorÉí·Ý½øÈëʱ£¬¿ÉÄÜ»áʹÓÃϵͳ¹ÜÀí³ÌÐòËùÔÚµÄPATHĿ¼£¬Èç: /sbin »ò /usr/sbin
Linux£¬like unix, ÔÚPATH±äÁ¿µÄentriesÖ®¼äÓÃcolon(:)·Ö¸ô£¬¶øwindowsºÍms-dosÓÃsemicolon (;) ·Ö¸ô¡£
Linux£ºÊ¹ÓÃforward slash (/) À´·Ö¸ôĿ¼
eg: /usr/bin/
windows: ʹÓÃbackward slash (\)À´·Ö¸ ......

linuxÇý¶¯Ö®mmapʵÀý

// Linux Device Driver Template/Skeleton with mmap
// Kernel Module
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <linux/vmalloc.h>
#include <linux/mman.h>
#include <linux/slab.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#include <linux/wrapper.h>
#endif
#define SKELETON_MAJOR 240
#define SKELETON_NAME "skeleton"
#define CASE1 1
#define CASE2 2
static unsigned int counter = 0;
static char string [128];
static int data;
//#define USEASCII
#ifdef USEASCII
static char *kmalloc_area = NULL;
static char *kmalloc_ptr = NULL;
#else
static unsigned int *kmalloc_area = NULL;
static unsigned int *kmalloc_ptr = NULL;
#endif
#define LEN (64*1024)
unsigned long virt_add ......

linuxÏÂdnw(6410)

ÍøÉÏÓÐÆªÌû×Ó°üº¬ÀïlinuxϵÄdnw£¬ÎÒÔÚÓÃidea6410£¬±àÒëdnwºÍsecbulkºó²¢²»ÄÜÕý³£Ê¹ÓÃ
LINUXϵÄDNW³ÌÐòÏÂÔØ
http://linux.chinaunix.net/bbs/viewthread.php?tid=1055992
secbulkÉ豸佨Á¢£¬ÊÖ¶¯½¨Á¢/dev/secbulk0²¢²»Æð×÷Óã¬Ô­ÒòÊÇsecbulk probe»áÆ¥Åäid_table£¬Õâ¸öÊÇΪQQ2440×¼±¸µÄ£¬ËùÒÔÐèÒª¸Äid_table
static struct usb_device_id secbulk_table[]= {
        { USB_DEVICE(0x04e8, 0x1234)},
        { }
};
¿ÉÒÔͨ¹ýlsusb»ñµÃidProductºÍidVendor,ÐèÒªÔÚ²åÉϰå×Ó£¬²¢×¼±¸ÏÂÔØÊ±´ËʱÉ豸Á¬ÉÏʱlsusb£¬0x04e8:0x1234¾ÍÊÇÎÒÐèÒªµÄ
[zhourr@localhost ~]$ lsusb
Bus 002 Device 005: ID 04e8:1234 Samsung Electronics Co., Ltd
Bus 002 Device 004: ID 064e:a116 Suyin Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 002: ID 093a:2510 Pixart Imaging, Inc.
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 067b:2303 ......

Linuxϵͳµ÷ÓÃ


¹¦ÄÜÃèÊö£º
»ñȡһЩÎļþÏà¹ØµÄÐÅÏ¢¡£
Ó÷¨£º
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *path, struct stat *buf);
int fstat(int filedes, struct stat *buf);
int lstat(const char *path, struct stat *buf);
²ÎÊý£º
path£ºÎļþ·¾¶Ãû¡£
filedes£ºÎļþÃèÊö´Ê¡£
buf£ºÊÇÒÔϽṹÌåµÄÖ¸Õë
struct stat {
   dev_t     st_dev;     /* ÎļþËùÔÚÉ豸µÄ±êʶ */
    ino_t     st_ino;     /* Îļþ½áµãºÅ */
   mode_t    st_mode;    /* Îļþ±£»¤Ä£Ê½ */
   nlink_t   st_nlink;   /* Ó²Á¬½ÓÊý */
   uid_t     st_uid;     /* ÎļþÓû§±êʶ */
   gid_t     st_gid;     /* ÎļþÓû§×é±êʶ */
   dev_t     st_rdev;    ......
×ܼǼÊý:40319; ×ÜÒ³Êý:6720; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [6124] [6125] [6126] [6127] 6128 [6129] [6130] [6131] [6132] [6133]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ