linuxÏÂudp¿Í»§¶ËÔ´ÂëʾÀý
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
typedef struct _NSS_HEADER
{
unsigned short ProtocolVersion; /* ÐÒé°æ±¾ÐÅÏ¢ */
unsigned short MsgType; /* ÏûÏ¢ÀàÐÍ */
unsigned short TransactionNo; /* ´«Êä±àºÅ */
unsigned short PacketLength; /* Êý¾Ý°ü³¤¶È,°üÀ¨Header */
}NSS_HEADER;
int main(int argc, char **argv)
{
printf("client ip: %s\n", argv[1]);
printf("client port: %s\n", argv[2]);
printf("server ip: %s\n", argv[3]);
printf("server port: %s\n", argv[4]);
printf("\n service starting...\n\n");
int socketFd;
struct sockaddr_in svrAddr;
struct sockaddr_in localAddr;
socketFd = socket (AF_INET, SOCK_DGRAM, 0);
if ( -1 == socketFd )
{
perror( "socket:" );
exit(-1);
}
// ÉèÖõØÖ·¿É¸´ÓÃ
int option = 1;
setsockopt( socketFd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option) );
// ¿Í»§¶ËIP
memset(&localAddr, 0, sizeof(localAddr));
localAddr.sin_family = AF_INET;
localAddr.sin_addr.s_addr = inet_addr( argv[1]);
localAddr.sin_port = htons (atoi(argv[2]));
int bindResult = bind(socketFd, (struct sockaddr *) &localAddr, sizeof(localAddr));
if ( -1 == bindResult )
{
perror( "bind:" );
sleep(10);
close(socketFd);
exit(-1);
}
// ·þÎñÆ÷IP
memset(&svrAddr, 0, sizeof(svrAddr));
svrAddr.sin_family = AF_INET;
svrAddr.sin_addr.s_addr = inet_addr( argv[3]);
svrAddr.sin_port = htons (atoi(argv[4]));
char tempBuff[2048] = {0};
// ÿ·ÖÖÓ·¢ËÍÒ»´ÎÊý¾Ý
NSS_HEADER hdr;
memset( &hdr, 0, siz
Ïà¹ØÎĵµ£º
Òý×Ô£ºhttp://server.it168.com/a2009/0309/267/000000267930.shtml
4.3 Linux½ø³Ì¹ÜÀíÃüÁîÏê½â£¨1£©
¡¡¡¡Linux¹ÜÀí½ø³ÌµÄ×îºÃ·½·¨¾ÍÊÇʹÓÃÃüÁîÐÐϵÄϵͳÃüÁî¡£LinuxÏÂÃæµÄ½ø³ÌÉæ¼°µÄÃüÁîÓÐat, bg, fg, kill, crontab, jobs, ps, pstree, top, nice, renice, sleep, nohup¡£
¡¡¡¡1£®atÃüÁ¶¨Ê±ÔËÐÐÃüÁî
¡¡¡¡×÷Ó㺠......
Òý×Ô£ºhttp://server.it168.com/a2009/0309/267/000000267918.shtml
4.1.7 LinuxµÄµÚÒ»¸ö½ø³Ì£ºinit£¨1£©
initÊÇLinuxϵͳִÐеĵÚÒ»¸ö½ø³Ì£¬½ø³ÌIDΪ1£¬ÊÇϵͳËùÓнø³ÌµÄÆðµã£¬Ö÷ÒªÓÃÀ´Ö´ÐÐһЩ¿ª»ú³õʼ»¯½Å±¾ºÍ¼àÊÓ½ø³Ì¡£LinuxϵͳÔÚÍê³ÉÄÚºËÒýµ¼ÒÔºó¾Í¿ªÊ¼ÔËÐÐinit³ÌÐò£¬init³ÌÐòÐèÒª¶ÁÈ¡ÅäÖÃÎļþ/etc/inittab¡£init ......
ÐéÄâ»úlinux°æ±¾£ºredhat9.0
×ܽáһϣºÒª±£Ö¤ÐéÄâ»úϵͳ¿ÉÒÔÉÏÍø£¬µÃÏȽâ¾öÐéÄâ»úºÍÕæʵÖ÷»úµÄÁ¬½Ó¹Øϵ¡£VMwareÖ÷Òª¸ø³ö3ÖÖģʽ£¬ÎÒÃdz£ÓõÄÓГbridge£¨ÇŽӣ©”ºÍ
“Nat£¨ÍøÂçµØַת»»£©”·½Ê½¡£ÐéÄâ»úÉèÖ÷½·¨£ºµ¥»÷“ÐéÄâ»ú”→“ÉèÖÔ→“ÒÔÌ«Íø£¬È»ºóÑ¡ÔñÁ ......
¹«Ë¾ÓиöÓÃARM940T×öµÄÊÖ³Öʽ²úÆ·£¬ÎÒÃÇÒÆÖ²ÁËÒ»¸öuClinuxÉÏÈ¥£¬ÏµÍ³»¹ÊÇÔËÐв»´íµÄ¡£
ÒòΪûÓдøÍø¿Ú£¬Ö»ÓÐUSBת´®¿Ú¿ÉÒÔʹÓã¬ËùÒÔÏëÑ°ÕÒÒ»¸öÎȶ¨µÄ´«Êä;¾¶£¬ÔÚhostºÍdeviceÖ®¼ä½»»»Îļþ¡£ÎÊÁ˺ܶàÈ˶¼²»Çå³þ£¬»¹ÊÇÒª¿¿×Ô¼ºÕÒ½â¾ö·½·¨¡£
ÔÚgoogleÉÏÕÒÁË°ëÌ죬ÖÕÓÚÕÒµ½ÁËÒ»¸ö¿ÉÒÔͨ¹ý´®¿Ú´«ËÍÎļþµÄÈí¼þ£¬Õâ¾ÍÊǹŶ¼ ......
linux shell pwd ÏÔʾµ±Ç°Â·¾¶
¼ÙÈôÓÐtest.cpp
g++ test.cpp -o test
./test
ÏëÔÚtestÖÐÕÒµ½µ±Ç°Ö´ÐгÌÐòËùÔڵķ¾¶
¿ÉÒÔÔÙtest.cppÖÐʹÓÃreadlinkº¯Êý
¾ßÌå¼ûÈçÏÂʵÀý£º
#include<iostream>
#include<unistd.h>
#include<dirent.h>
#include<string.h>
#include<string>
using ......