⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monkey.c.bak

📁 基于linux的http服务器.代码比较简单
💻 BAK
字号:
/*  Monkey HTTP Daemon v0.1.1 by EdsipeR (edsiper@linux-chile.org) *  -------------------------------------------------------------- *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU Library General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <string.h>#include <stdio.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <stdlib.h>#include <sys/stat.h>#include "config.h"#include "request.h"#include "version.h"int reset(int local_fd) {		int status=1;		if(setsockopt(local_fd,SOL_SOCKET,SO_REUSEADDR,&status,sizeof(int))==-1) {		perror("setsockopt");		exit(1);	}			return local_fd;}int main(int argc, char** argv) {	int local_fd, remote_fd;	int sin_size;	struct sockaddr_in local;	struct sockaddr_in remote;		infoversion();		if(argv[1]==NULL) {		puts("Usar: monkey directorio/conf");		exit(0);	}		printf("kdkd: %s\n", argv[1]);		up_mimetypes(argc,argv);	up_config(argc,argv);				local_fd=socket(AF_INET,SOCK_STREAM,0);	local.sin_family=AF_INET;	local.sin_port=htons(SERVERPORT);	local.sin_addr.s_addr=INADDR_ANY;	memset(&(local.sin_zero),'\0',8);		reset(local_fd); /* Reset Socket */			if(bind(local_fd,(struct sockaddr *)&local,sizeof(struct sockaddr))!=0){		puts("Error: El puerto de conexion esta ocupado...");		exit(1);	}		     		if((listen(local_fd,10))!=0)		perror("listen");			while(1) {		sin_size=sizeof(struct sockaddr_in);   	 if( (remote_fd=accept(local_fd,&remote,&sin_size))==-1 )			perror("accept");		request(remote_fd);	}		close(local_fd);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -