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

linux Socket±à³ÌÈëÃÅ

ÒÔÇ°ÒѾ­½Ó´¥WindowsϵÄSocket±à³Ì£¬×î½üÒ²³¢ÊÔ×ÅÔÙlinuxÏÂʹÓÃSocket±à³Ì£¬ÏÂÃæÊÇÔÚÍøÉÏÕÒµÄÀý×Ó(ÒѾ­²âÊÔ¹ý)
 tcp_server.c:
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <time.h>
#define SERVER_PORT 20000
#define LENGTH_OF_LISTEN_QUEUE 10
#define BUFFER_SIZE 255
#define WELCOME_MESSAGE "welcome to connect the server"
int main(int argc, char **argv)
{
 int servfd,clifd;
 struct sockaddr_in servaddr,cliaddr;
 if((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
 {
  printf("create socket error!\n");
  exit(1);
 }
 bzero(&servaddr, sizeof(servaddr));
 servaddr.sin_family = AF_INET;
 servaddr.sin_port = htons(SERVER_PORT);
 servaddr.sin_addr.s_addr = htons(INADDR_ANY);
 
 if(bind(servfd,(struct sockaddr*)&servaddr,sizeof(servaddr)) < 0)
 {
  printf ("bind to port %d failure!\n",SERVER_PORT);
  exit(1);
 }
 
 if(listen(servfd, LENGTH_OF_LISTEN_QUEUE) < 0)
 {
  printf("call listen failure!\n");
  exit(1);
 }
 while(1)
 {
  char buf[BUFFER_SIZE];
  long timestamp;
  socklen_t length = sizeof(cliaddr);
  clifd = accept(servfd, (struct sockaddr*)&cliaddr, &length);
  if(clifd < 0)
  {
   printf("error comes when call accept!\n");
   break;
  }
  strcpy(buf,WELCOME_MESSAGE);
  printf("from client, IP:%s, Port:%d\n", inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port));
  timestamp = time(NULL);
  strcat(buf, "timestamp in server:");
  strcat(buf, ctime(&timestamp));
  send(clifd, buf, BUFFER_SIZE, 0);
  close(clifd);
 }
 close(servfd);
 return 0;
}
tcp_clie


Ïà¹ØÎĵµ£º

½¨Á¢»ùÓÚlinuxµÄMIPS½»²æ±àÒë»·¾³

 ×÷Õߣº·ëÀÚ (flw10000) MAIL£ºflw10000 AT 163.com
¾­¹ý½üÒ»ÖܵÄæºõ£¬°Ñ»ùÓÚlinuxµÄMIPS½»²æ±àÒë»·¾³»ù±¾´î½¨³É¹¦£¬ÕâÀï˵"»ù±¾"´î½¨³É¹¦ÊÇÒòΪ»·¾³ËäÈ»´î½¨ºÃÁË£¬¿ÉÒÔ±àÒë»ùÓڣͣɣУӵĿÉÖ´ÐÐÎļþÁË£¬µ«»¹Ã»ÓÐÔÚÕæÕýµÄ£Í£É£Ð£Ó»·¾³Ï²âÊÔ¹ý£¬»¹ÓÐÔÚ±àÒëµÄ¹ý³ÌÖгöÏÖÁËЩÎÊÌ⣬ËäÈ»½â¾öÁË£¬Ò²ÒòûÓÐÔÚÕæÕýµÄ£Í£É£ ......

ÔÚLinuxÏÂÓÃbuildroot´î½¨mips/armµÄ½»²æ±àÒëƽ̨

 ÔÚLinuxÏÂÓÃbuildroot´î½¨mips/armµÄ½»²æ±àÒëƽ̨
Õâ¸ö±àÒë»·¾³ÊDz»ÄܱàÒëfor¿ªÔ´ÎÞÏß·ÓÉÆ÷µÄ³ÌÐòµÄ£¬ÒòΪÄÚºËÊÇ2.6µÄ
½¨Òé²Î¿¼Õâƪ: http://www.felix021.com/blog/read.php?1467
Ç°Á½ÌìÂòÁËNetGear WRT614 V9£¬´îÔصÄÊÇBroadcomµÄ200MHz MIPS´¦ÀíÆ÷¡£
ÓÉÓÚʹÓõÄÊÇ¿ªÔ´²Ù×÷ϵͳLinux£¬ËùÒÔ¿ÉÒÔË¢ÍøÉÏһЩNBµÄ ......

LinuxÄÚ´æ¹ÜÀíÖ®slab·ÖÅäÆ÷·ÖÎö(Ðø¶þ)

 Î壺kmem_cache_create£¨£©·ÖÎö
ÎÒÃÇÒÔÒ»¸öÀý×ÓÀ´¸ú×Ù·ÖÎöÒ»ÏÂslabµÄ»úÖÆ£º
ÏÂÃæÊÇÒ»¸ö²âÊÔÄ£¿éµÄ´úÂ룺
#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
 
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ericxiao <xgr178@163.com>");
MODULE_DESCRI ......

LinuxÏ c ÅжÏÒ»¸öÎļþÊÇ·ñ´æÔÚ

#include <stdio.h>
#include <unistd.h>
#define FOO "foo"
int main(void)
{
if(!access(FOO, F_OK))
{
if(!unlink(FOO))
{

}
else
{
printf("remove %s failed\n", FOO);
}
}
else
{
printf("%s not existed\ ......

ÁгöLinuxÔ´ÂëÏÂËùÓÐMakefileµÄ·½·¨

 Ò»¡¢ÒªÇó£º
1¡¢Äܹ»ÏÔʾ³öMakefileµÄ×ÜÊý
2¡¢ÄÜÏÔʾһ¼¶Ä¿Â¼ÏµÄMakefile×ÜÊý¡¢MakefileÁÐ±í¼°ÆäMakefileµÄÄÚÈÝ
3¡¢Äܽ«ÉÏÊöÄÚÈÝдÈëÏàÓ¦µÄÎļþ
¶þ¡¢ÊµÀý
rm -rf ~/Desktop/linux_Makefile/*
for i in `find . -maxdepth 1 -type d`
#½ö½öÊǵ±Ç°Ä¿Â¼£¬ËùÒÔÇ뽫±¾½Å±¾·ÅÔÚlinuxÔ´ÂëĿ¼ÏÂÖ´ÐС£
do
 e ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ