23,110
社区成员
发帖
与我相关
我的任务
分享
char IPPORT[25]={0};
const char* ss="192.168.1.1:5533";
strcpy(IPPORT,ss);
int in=0;
char *p[2]={0};
char c_port[]="80";//默认80端口
char *buf=IPPORT;
INFO("BUF=%s",buf);
char *outer_ptr=NULL;
int port=0;
char *ip;
char *ps;
ps=strchr(buf,':');
if(ps){
INFO("PS");
while((p[in] = strtok_r(buf,":",&outer_ptr))!=NULL){
in++;
buf=NULL;
}
if(p[1]==NULL){
INFO("IP IS NUMM");
p[1]=c_port;
}
port=atoi(p[1]);
ip=p[0];
printf("p[0]=%s,p[1]=%s\n",p[0],p[1]);
}
else{
INFO("###################");
ip=buf;
port=80;
}
INFO("IP=%s,PORT=%d",ip,port);