use ggg
This commit is contained in:
parent
037cb803cc
commit
5dba0df6ac
@ -1,7 +1,8 @@
|
|||||||
void runtime_call(){
|
void runtime_call(){
|
||||||
char a;
|
char a;
|
||||||
|
char b;
|
||||||
printf("input connection mode\n");
|
printf("input connection mode\n");
|
||||||
scanf("%c",&a);
|
scanf("%c%c",&a,&b);
|
||||||
for(;a!='q';){
|
for(;a!='q';){
|
||||||
if(a=='1'){
|
if(a=='1'){
|
||||||
//sync
|
//sync
|
||||||
@ -9,12 +10,13 @@ void runtime_call(){
|
|||||||
}
|
}
|
||||||
else if(a=='2'){
|
else if(a=='2'){
|
||||||
//trans
|
//trans
|
||||||
|
trans_client();
|
||||||
}
|
}
|
||||||
else if(a=='3'){
|
else if(a=='3'){
|
||||||
//http
|
//http
|
||||||
}
|
}
|
||||||
printf("input connection mode again\n");
|
printf("input connection mode again\n");
|
||||||
scanf("%c",&a);
|
scanf("%c%c",&a,&b);
|
||||||
}
|
}
|
||||||
send(sockad,&a,1,0);
|
send(sockad,&a,1,0);
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,13 @@ void sync_client(){
|
|||||||
send(sockad,&a,1,0);
|
send(sockad,&a,1,0);
|
||||||
char *s;
|
char *s;
|
||||||
s=(char *)malloc(1024*sizeof(char));
|
s=(char *)malloc(1024*sizeof(char));
|
||||||
scanf("%c",&a);
|
|
||||||
num=sync_get(s);
|
num=sync_get(s);
|
||||||
for(;;){
|
for(;;){
|
||||||
send(sockad,s,num,0);
|
send(sockad,s,num,0);
|
||||||
printf("keep or not?[Y/N]\n");
|
printf("keep or not?[Y/N]\n");
|
||||||
scanf("%c",&a);
|
scanf("%c%c",&a,&b);
|
||||||
scanf("%c",&b);
|
|
||||||
send(sockad,&a,1,0);
|
send(sockad,&a,1,0);
|
||||||
if(a=='N'|a=='n'){
|
if(a=='N'||a=='n'){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
num=sync_get(s);
|
num=sync_get(s);
|
||||||
|
69
client/func/trans_client.c
Normal file
69
client/func/trans_client.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
void trans_client(){
|
||||||
|
char a='2';
|
||||||
|
send(sockad,&a,1,0);
|
||||||
|
char b;
|
||||||
|
|
||||||
|
printf("send or get or quit?[S/G/Q]\n");
|
||||||
|
scanf("%c%c",&a,&b);
|
||||||
|
send(sockad,&a,1,0);
|
||||||
|
|
||||||
|
|
||||||
|
for(;a!='Q'&&a!='q';){
|
||||||
|
if(a=='S'||a=='s'){
|
||||||
|
trans_c_send(name);
|
||||||
|
}
|
||||||
|
else if(a=='G'||a=='g'){
|
||||||
|
trans_c_get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("send or get or quit?[S/G/Q]\n");
|
||||||
|
scanf("%c%c",&a,&b);
|
||||||
|
send(sockad,&a,1,0);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_c_send(char *name){
|
||||||
|
char *name;
|
||||||
|
name=(char *)malloc(sizeof(char)*128);
|
||||||
|
int num_name;
|
||||||
|
memset(name,0,128*sizeof(char));
|
||||||
|
printf("input the name of file:");
|
||||||
|
scanf("%s",name);
|
||||||
|
num_name=strlen(name);
|
||||||
|
send(sockad,name,num_name,0);
|
||||||
|
|
||||||
|
free(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
void trans_c_get(char *name){
|
||||||
|
char *name;
|
||||||
|
name=(char *)malloc(sizeof(char)*128);
|
||||||
|
int num_name;
|
||||||
|
memset(name,0,128*sizeof(char));
|
||||||
|
printf("input the name of file:");
|
||||||
|
scanf("%s",name);
|
||||||
|
num_name=strlen(name);
|
||||||
|
send(sockad,name,num_name,0);
|
||||||
|
|
||||||
|
free(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void itc(int num_name,char *num_name_char){
|
||||||
|
int a;
|
||||||
|
int i;
|
||||||
|
int m;
|
||||||
|
for(i=0;i<3;i++){
|
||||||
|
m=2-i;
|
||||||
|
m=(int)pow(10,m);
|
||||||
|
a=num_name/m;
|
||||||
|
num_name=num_name-a*m;
|
||||||
|
num_name_char[i]=a+48;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
@ -1,13 +1,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
||||||
|
|
||||||
#include "func/init_con.c"
|
#include "func/init_con.c"
|
||||||
#include "func/runtime_call.c"
|
#include "func/runtime_call.c"
|
||||||
#include "func/sync_client.c"
|
#include "func/sync_client.c"
|
||||||
|
@ -9,6 +9,7 @@ void runtime_call(){
|
|||||||
}
|
}
|
||||||
else if(a=='2'){
|
else if(a=='2'){
|
||||||
//trans
|
//trans
|
||||||
|
trans_server();
|
||||||
}
|
}
|
||||||
else if(a=='3'){
|
else if(a=='3'){
|
||||||
//http
|
//http
|
||||||
|
@ -9,7 +9,7 @@ void sync_server(){
|
|||||||
s[num]='\0';
|
s[num]='\0';
|
||||||
printf("get chars:%s\n",s);
|
printf("get chars:%s\n",s);
|
||||||
recv(sockad,&a,1,0);
|
recv(sockad,&a,1,0);
|
||||||
if(a=='N'|a=='n'){
|
if(a=='N'||a=='n'){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(s,0,1024*sizeof(char));
|
memset(s,0,1024*sizeof(char));
|
||||||
|
36
server/func/trans_server.c
Normal file
36
server/func/trans_server.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
void trans_server(){
|
||||||
|
char a;
|
||||||
|
//client get or send or quit
|
||||||
|
recv(sockad,&a,1,0);
|
||||||
|
|
||||||
|
|
||||||
|
for(;a!='Q'&&a!='q';){
|
||||||
|
if(a=='S'||a=='s'){
|
||||||
|
trans_s_get();
|
||||||
|
}
|
||||||
|
else if(a=='G'||a=='g'){
|
||||||
|
trans_s_send();
|
||||||
|
}
|
||||||
|
recv(sockad,&a,1,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_s_get(){
|
||||||
|
char *name;
|
||||||
|
name=(char *)malloc(sizeof(char)*128);
|
||||||
|
int num_name;
|
||||||
|
memset(name,0,128*sizeof(char));
|
||||||
|
num_name=recv(sockad,name,128,0);
|
||||||
|
free(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_s_send(){
|
||||||
|
char *name;
|
||||||
|
name=(char *)malloc(sizeof(char)*128);
|
||||||
|
int num_name;
|
||||||
|
memset(name,0,128*sizeof(char));
|
||||||
|
num_name=recv(sockad,name,128,0);
|
||||||
|
free(name);
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
||||||
|
15
test/name.c
Normal file
15
test/name.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
char *name;
|
||||||
|
int b;
|
||||||
|
name=(char *)malloc(128*sizeof(char));
|
||||||
|
memset(name,0,128*sizeof(char));
|
||||||
|
scanf("%s",name);
|
||||||
|
b=strlen(name);
|
||||||
|
printf("%d",name[4]);
|
||||||
|
printf("\nnum:%d",b);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user