1.config文件是源码什么文件?
2.å¼åAPPè¦ç¨ä»ä¹è½¯ä»¶å¼åï¼
3.linux下socket 网络编程(客户端向服务器端发送文件) 求源代码 大哥大姐帮帮忙 。。源码谢谢
config文件是源码什么文件?
config分很多种情况:1)作为扩展名的时候比如.net站点下有app.config,还有web.config.
2)config.xml文件是AppCan移动App的配置文件,用于指定应用的显示名称、图标、源码cf基址源码应用起始页地址及需要使用的源码设备权限等信息
3)config.pro文件是我们使用Proe时设置属于自己的系统参数,界面
4)config.ini文件:
4.1,这个是源码短信提醒接口源码程序.exe执行文件的配置文件。
4.2,源码一般.ini都为配置文件。源码
4.3,源码如果没必要,源码不要删除,源码一般执行程序,源码丢了配置文件,源码淘宝商铺源码实战会报错误。源码
4.4,源码有的王者战纪源码丢了配置文件,再次执行程序时,会自动生成的。
环境安装,emlog博客网站源码配置等问题可以参考: config.net.cn
具体参考:config配置文件的读取,写入与修改生效,含源码及统一配置
å¼åAPPè¦ç¨ä»ä¹è½¯ä»¶å¼åï¼
APPå¶ä½æ¹æ³ï¼1ãå½å¤çå¶ä½å·¥å ·Appmakrã
è¿ä¸ªå·¥å ·æ¯å½å¤çï¼æå¼å§ä¸æ¯æä¸æï¼ä½ç°å¨ä¹å·²ç»æ¯æä¸æäºï¼ä½ å¯ä»¥æ ¹æ®èªå·±çæ åµéæ©å¶ä½å·¥å ·ï¼æä¸é¢è¿ä¼ä»ç»å 个å½å çã
ä¸ç¨åä¸è¡ä»£ç å°±è½åAppï¼Appmakrè½å¸®å©ä¸ä¼å代ç çæ®éç¨æ·çæèªå·±çAppãAppMakrç使ç¨ç¸å½ç®åï¼åªè¦ç»å½ç½ç«ï¼æ³¨åä¸ä¸ªè´¦æ·ï¼æå¨é¼ æ å®å¶ä¸äºç®åçæé®ä¸æ ç®ï¼ç¡®å®å¥½çé¢é¢è²ï¼å¨ç¼è¾å¨å³ä¾§ç模æå¨ä¸ç好é¢è§ææï¼åçæåºç¨å°±è¡äºã
2ãå½å å¶ä½å·¥å ·AppCanã
.AppCanæ¯å½å çä¸ä¸ªç§»å¨åºç¨å¼åå¹³å°ï¼æ¯æ跨平å°åºç¨å¼åï¼æ¯æHybrid Appçå¼ååè¿è¡ãAppCanåºç¨å¼ææä¾çNative交äºè½åï¼å¯ä»¥è®©HTML5å¼åç移å¨åºç¨åºæ¬æ¥Native Appçä½éªã
3ãå½å å¶ä½å·¥å ·Appbymeã
Appbymeï¼å®ç±³ç½ï¼æ¯æ©è®¯å ¬å¸å¼åçä¸æ¬¾åºç¨çæå·¥å ·ï¼å¹´3æ份ä¸çº¿ï¼æªæ¢ç°å¨ï¼Appbymeå·²ç»è¿è¥æ¬¾APPï¼ç¨æ·æ°éè¶ è¿ä¸ãç®åæ¯æçå¹³å°æiOSåAndroidã
4ãå½å å¶ä½å·¥å ·å¤æ©ã
å¤æ©APPå¹³å°ï¼ä¹æ¯ä¸æ¬¾è½å¤å¿«éå建APPç¨åºçå¹³å°ï¼ä¼ä¸æ个人é½å¯ä»¥éè¿è¿ä¸ªå¹³å°å建ä¸ä¸ªå ³äºä¼ ä¸æ个人çææºAPPç¨åºï¼å¯ä»¥åºç¨äºä¼ä¸æ´»å¨ï¼ä¼ä¸äº§åæ¨å¹¿ï¼ä¸ªäººåçï¼ä¸ªäººä¸å¡çæ¹é¢ã让ä¼ä¸æ个人å®ç°çæ£ç移å¨çµååå¡ã
æ©å±èµæï¼
androidåºç¨å¼åï¼æåºæ¬çæ¯éè¦æå¾ç¨Javaè¯è¨åXMLç¥è¯ãææ¡äºè¿ä¸¤ç§è¯è¨ååè£ ä¸ªEclipseåAndroid SDK, å°±å¯ä»¥åå¼åäºã
JavaåXMLåªæ¯ç¼ç¨åºç¡ï¼å¦æå¸ææ为iOSåºç¨å¼åè ï¼é£ä¹éè¦ç¥éï¼
1ãè¯è¨åºç¡ï¼Objective-Cè¯è¨ãxcodeå¼åç¯å¢ã
2ãææºä½¿ç¨ç»éªï¼è¶³å¤çiPhone使ç¨ç»éªä¸ä½ä¼ï¼ä¸ç¶ä½ å¾é¾ä¸äº§åç»çå设计人åæææ²éã
3ãå ·ä½çå¼åè½åï¼ä¸»è¦çå¼åå°éä¸äºçé¢å¼åãä¸å®çæ°æ®åºå¼åãé讯æ¥å£å¼åãååå¼åä¸èè°ï¼å¦ææ¯æ¸¸æï¼é£ä¹è¿éè¦æ¶åå°å¼æã建模ãç´ æãå å½±ãæ äºæ¿çãæ¨è两æ¬ä¹¦ä¸¤æ¬ç»å ¸å ¥é¨ä¹¦ç±ãobjective-cåºç¡æç¨ãåãiphone4åipadå¼ååºç¡æç¨ãã
åèèµææ¥æºï¼
ç¾åº¦ç¾ç§ââAppmakr
ç¾åº¦ç¾ç§ââAppCan
ç¾åº¦ç¾ç§ââAppbyme
linux下socket 网络编程(客户端向服务器端发送文件) 求源代码 大哥大姐帮帮忙 。。谢谢
server:
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <syslog.h>
#include <sys/time.h>
#include <string.h>
#include <fcntl.h>
#include <sys/wait.h>
#define MAXDATASIZE
#define SERVPORT
#define BACKLOG
int SendFileToServ(const char *path, const char *FileName, const char *ip)
{
#define PORT
int sockfd;
int recvbytes;
char buf[MAXDATASIZE];
char send_str[MAXDATASIZE];
char filepath[] = { 0};
struct sockaddr_in serv_addr;
FILE *fp;
sprintf(filepath, "%s%s", path, FileName);
if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1)
{
perror("socket");
return 1;
}
bzero(&serv_addr,sizeof(struct sockaddr_in));
serv_addr.sin_family=AF_INET;
serv_addr.sin_port=htons(PORT);
inet_aton(ip, &serv_addr.sin_addr);
int IErrCount = 0;
again:
if(connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(struct sockaddr))==-1)
{
if (5 == IErrCount)
return 1;
IErrCount++;
perror("connect");
sleep(2);
goto again;
}
//if ((fp = fopen(FileName, "rb")) == NULL)
if ((fp = fopen(filepath, "rb")) == NULL)
{
perror("fopen ");
return 1;
}
recvbytes = write(sockfd, FileName, strlen(FileName));
recvbytes = read(sockfd, buf, MAXDATASIZE);
if (!memcmp(buf, "sendmsg", 7))
{
while(fgets(send_str, MAXDATASIZE, fp))
{
recvbytes = write(sockfd, send_str, strlen(send_str));
recvbytes = read(sockfd, buf, MAXDATASIZE);
if (recvbytes <= 0)
{
fclose(fp);
close(sockfd);
return 1;
}
if (memcmp(buf, "goon", 4))
{
fclose(fp);
close(sockfd);
return 1;
}
}
recvbytes = write(sockfd, "end", 3);
}
else
{
fclose(fp);
close(sockfd);
return 1;
}
memset(buf, 0, MAXDATASIZE);
if (read(sockfd, buf, MAXDATASIZE) <= 0)
{
close(sockfd);
return 2;
}
char *Eptr = "nginx reload error";
//printf("bf[%s]\n", buf);
int ret;
ret = strncmp(buf, Eptr, strlen(Eptr));
//printf("%d\n", ret);
if (!ret)
{
close(sockfd);
return 2;
}
close(sockfd);
return 0;
}
int mysyslog(const char * msg)
{
FILE *fp;
if ((fp = fopen("/tmp/tmp.log", "a+")) == NULL)
{
return 0;
}
fprintf(fp, "[%s]\n", msg);
fclose(fp);
return 0;
}
static void quit_handler(int signal)
{
kill(0, SIGUSR2);
syslog( LOG_NOTICE, "apuserv quit...");
// do something exit thing ,such as close socket ,close mysql,free list
// .....
//i end
exit(0);
}
static int re_conf = 0;
static void reconf_handler(int signal)
{
re_conf=1;
syslog(LOG_NOTICE,"apuserv reload configure file .");
// 请在循环体中判断,如果re_conf == 1,请再次加载配置文件。
}
static int isrunning(void)
{
int fd;
int ret;
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = 0;
lock.l_start = 0;
lock.l_len = 0;
const char *lckfile = "/tmp/apuserv.lock";
fd = open(lckfile,O_WRONLY|O_CREAT);
if (fd < 0) {
syslog(LOG_ERR,"can not create lock file: %s\n",lckfile);
return 1;
}
if ((ret = fcntl(fd,F_SETLK,&lock)) < 0) {
ret = fcntl(fd,F_GETLK,&lock);
if (lock.l_type != F_UNLCK) {
close(fd);
return lock.l_pid;
}
else {
fcntl(fd,F_SETLK,&lock);
}
}
return 0;
}
int MyHandleBuff(const char *buf, char *str, char *FileName, char *pth)
{
sscanf(buf, "%s %s %s", pth, FileName, str);
printf("path=%s\nfilename=%s\nip=%s\n", pth, FileName, str);
return 0;
}
int main(int argc, char **argv)
{
int sockfd,client_fd;
socklen_t sin_size;
struct sockaddr_in my_addr,remote_addr;
char buff[MAXDATASIZE];
int recvbytes;
#if 1
int pid ;
char ch ;
int ret;
int debug = 0;
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGTERM, quit_handler);
syslog(LOG_NOTICE,"apuserver start....");
while ((ch = getopt(argc, argv, "dhV")) != -1) {
switch (ch) {
case 'd':
debug = 1;
break;
case 'V':
printf("Version:%s\n","1.0.0");
return 0;
case 'h':
printf(" -d use daemon mode\n");
printf(" -V show version\n");
return 0;
default:
printf(" -d use daemon mode\n");
printf(" -V show version\n");
}
}
if (debug && daemon(0,0 ) ) {
return -1;
}
if (isrunning()) {
fprintf(stderr, "apuserv is already running\n");
syslog(LOG_INFO,"apuserv is already running\n");
exit(0);
}
while (1) {
pid = fork();
if (pid < 0)
return -1;
if (pid == 0)
break;
while ((ret = waitpid(pid, NULL, 0)) != pid) {
syslog(LOG_NOTICE, "waitpid want %d, but got %d", pid, ret);
if (ret < 0)
syslog(LOG_NOTICE, "waitpid errno:%d", errno);
}
kill(0, SIGUSR2);
sleep(1);
syslog(LOG_NOTICE,"restart apuserver");
}
signal(SIGHUP, reconf_handler);
signal(SIGPIPE, SIG_IGN);
signal(SIGUSR1,SIG_IGN);
signal(SIGUSR2, SIG_DFL);
signal(SIGTERM, SIG_DFL);
#endif
if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1)
{
perror("socket");
exit(1);
}
bzero(&my_addr,sizeof(struct sockaddr_in));
my_addr.sin_family=AF_INET;
my_addr.sin_port=htons(SERVPORT);
my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if(bind(sockfd,(struct sockaddr *)&my_addr,sizeof(struct sockaddr))==-1)
{
perror("bind");
exit(1);
}
if(listen(sockfd,BACKLOG)==-1)
{
perror("listen");
exit(1);
}
int nret;
while(1)
{
sin_size = sizeof(struct sockaddr_in);
if((client_fd = accept(sockfd, (struct sockaddr *)&remote_addr, &sin_size))==-1)
{
perror("falied accept");
continue;
}
memset(buff, 0, MAXDATASIZE);
recvbytes = read(client_fd, buff, MAXDATASIZE);
char str[] = { 0};
char FileName[] = { 0};
char path[] = { 0};
MyHandleBuff(buff, str, FileName, path);
if (recvbytes > 0)
{
nret = SendFileToServ(path, FileName, str);
printf("nret[%d]\n", nret);
if (1 == nret)
write(client_fd, "send file error", );
else if(2 == nret)
write(client_fd, "reload nginx error", );
else
write(client_fd, "succ", 4);
}
close(client_fd);
}
}
_________________________________________________
client:
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <syslog.h>
#include <sys/time.h>
#include <string.h>
#include <fcntl.h>
#include <sys/wait.h>
#define MAXDATASIZE
#define SERVPORT
#define BACKLOG
int mysyslog(const char * msg)
{
FILE *fp;
if ((fp = fopen("/tmp/tmp.log", "a+")) == NULL)
{
return 0;
}
fprintf(fp, "[%s]\n", msg);
fclose(fp);
return 0;
}
static void quit_handler(int signal)
{
kill(0, SIGUSR2);
syslog( LOG_NOTICE, "apuserv quit...");
// do something exit thing ,such as close socket ,close mysql,free list
// .....
//i end
exit(0);
}
static int re_conf = 0;
static void reconf_handler(int signal)
{
re_conf=1;
syslog(LOG_NOTICE,"apuserv reload configure file .");
// ·1nf == 1£′μ?
static int isrunning(void)
{
int fd;
int ret;
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = 0;
lock.l_start = 0;
lock.l_len = 0;
const char *lckfile = "/tmp/dstserver.lock";
fd = open(lckfile,O_WRONLY|O_CREAT);
if (fd < 0) {
syslog(LOG_ERR,"can not create lock file: %s\n",lckfile);
return 1;
}
if ((ret = fcntl(fd,F_SETLK,&lock)) < 0) {
ret = fcntl(fd,F_GETLK,&lock);
if (lock.l_type != F_UNLCK) {
close(fd);
return lock.l_pid;
}
else {
fcntl(fd,F_SETLK,&lock);
}
}
return 0;
}
int main(int argc, char **argv)
{
int sockfd,client_fd;
socklen_t sin_size;
struct sockaddr_in my_addr,remote_addr;
char buff[MAXDATASIZE];
int recvbytes;
#if 1
int pid ;
char ch ;
int ret;
int debug = 0;
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGTERM, quit_handler);
syslog(LOG_NOTICE,"dstserver start....");
while ((ch = getopt(argc, argv, "dhV")) != -1) {
switch (ch) {
case 'd':
debug = 1;
break;
case 'V':
printf("Version:%s\n","1.0.0");
return 0;
case 'h':
printf(" -d use daemon mode\n");
printf(" -V show version\n");
return 0;
default:
printf(" -d use daemon mode\n");
printf(" -V show version\n");
}
}
if (debug && daemon(0,0 ) ) {
return -1;
}
if (isrunning()) {
fprintf(stderr, "dstserver is already running\n");
syslog(LOG_INFO,"dstserver is already running\n");
exit(0);
}
while (1) {
pid = fork();
if (pid < 0)
return -1;
if (pid == 0)
break;
while ((ret = waitpid(pid, NULL, 0)) != pid) {
syslog(LOG_NOTICE, "waitpid want %d, but got %d", pid, ret);
if (ret < 0)
syslog(LOG_NOTICE, "waitpid errno:%d", errno);
}
kill(0, SIGUSR2);
sleep(1);
syslog(LOG_NOTICE,"restart apuserver");
}
signal(SIGHUP, reconf_handler);
signal(SIGPIPE, SIG_IGN);
signal(SIGUSR1,SIG_IGN);
signal(SIGUSR2, SIG_DFL);
signal(SIGTERM, SIG_DFL);
#endif
if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1)
{
perror("socket");
exit(1);
}
bzero(&my_addr,sizeof(struct sockaddr_in));
my_addr.sin_family=AF_INET;
my_addr.sin_port=htons(SERVPORT);
my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if(bind(sockfd,(struct sockaddr *)&my_addr,sizeof(struct sockaddr))==-1)
{
perror("bind");
exit(1);
}
if(listen(sockfd,BACKLOG)==-1)
{
perror("listen");
exit(1);
}
char filepath[MAXDATASIZE]= { 0};
FILE *fp;
while(1)
{
sin_size = sizeof(struct sockaddr_in);
if((client_fd = accept(sockfd, (struct sockaddr *)&remote_addr, &sin_size))==-1)
{
perror("falied accept");
continue;
}
memset(buff, 0, MAXDATASIZE);
recvbytes = read(client_fd, buff, MAXDATASIZE);
sprintf(filepath, "/etc/nginx/url_rule/%s", buff);
if ((fp = fopen(filepath, "wb")) == NULL)
{
perror("fopen");
close(client_fd);
continue;
}
write(client_fd, "sendmsg", 7);
while(read(client_fd, buff, MAXDATASIZE))
{
if (!memcmp(buff, "end", 3))
{
fclose(fp);
break;
}
else
{
fprintf(fp, "%s", buff);
write(client_fd, "goon", 4);
}
}
//system("nginx -s reload");
char *Sptr = "nginx reload succ";
char *Eptr = "nginx reload error";
int ret;
ret = system("nginx -s reload");
printf("ret[%d]\n", ret);
if (ret != 0)
{
write(client_fd, Eptr, strlen(Eptr));
}
else
{
write(client_fd, Sptr, strlen(Sptr));
}
close(client_fd);
}
}
以前写的:内容忘记了。不是很复杂你可以自己看!