[分享] Linux下用Anjuta写个Hello World 的C++程序竟如此简单!
时间:2010-10-17
来源:互联网
代码:
/* TCP Socket functions; */
int tcp_init()
{
return socket(PF_INET,SOCK_STREAM,0);
}
int tcp_connect(int st,ATBD* info)
{
struct sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_port=htons(info->at_port);
sa.sin_addr.s_addr=inet_addr(info->at_address);
if(connect(st,(struct sockaddr*)&sa,sizeof(struct sockaddr_in))<0)
{
pmlog(strerror(errno));
return -1;
}
return 0;
}
/* The struct below is used to authorization; */
typedef struct _auth_bundle
{
char at_hostname[128]; /* The server's hostname; */
char at_address[16]; /* The server's IP address; */
int at_port; /* The number of port which is used to communication; */
char at_username[64]; /* Username; */
char at_password[64]; /* Password; */
char at_username_base64[96]; /* Username, after base64; */
char at_password_base64[96]; /* Password, after base64; */
} ATBD;
int tcp_init()
{
return socket(PF_INET,SOCK_STREAM,0);
}
int tcp_connect(int st,ATBD* info)
{
struct sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_port=htons(info->at_port);
sa.sin_addr.s_addr=inet_addr(info->at_address);
if(connect(st,(struct sockaddr*)&sa,sizeof(struct sockaddr_in))<0)
{
pmlog(strerror(errno));
return -1;
}
return 0;
}
/* The struct below is used to authorization; */
typedef struct _auth_bundle
{
char at_hostname[128]; /* The server's hostname; */
char at_address[16]; /* The server's IP address; */
int at_port; /* The number of port which is used to communication; */
char at_username[64]; /* Username; */
char at_password[64]; /* Password; */
char at_username_base64[96]; /* Username, after base64; */
char at_password_base64[96]; /* Password, after base64; */
} ATBD;
每次connect都超时。但是不封装能够连接上。请问如何解决?
作者: leycn 发布时间: 2010-10-17
代码:
/* TCP Socket functions; */
int tcp_init()
{
return socket(PF_INET,SOCK_STREAM,0);
}
int tcp_connect(int st,ATBD* info)
{
struct sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_port=htons(info->at_port);
sa.sin_addr.s_addr=inet_addr(info->at_address);
if(connect(st,(struct sockaddr*)&sa,sizeof(struct sockaddr_in))<0)
{
pmlog(strerror(errno));
return -1;
}
return 0;
}
/* The struct below is used to authorization; */
typedef struct _auth_bundle
{
char at_hostname[128]; /* The server's hostname; */
char at_address[16]; /* The server's IP address; */
int at_port; /* The number of port which is used to communication; */
char at_username[64]; /* Username; */
char at_password[64]; /* Password; */
char at_username_base64[96]; /* Username, after base64; */
char at_password_base64[96]; /* Password, after base64; */
} ATBD;
int tcp_init()
{
return socket(PF_INET,SOCK_STREAM,0);
}
int tcp_connect(int st,ATBD* info)
{
struct sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_port=htons(info->at_port);
sa.sin_addr.s_addr=inet_addr(info->at_address);
if(connect(st,(struct sockaddr*)&sa,sizeof(struct sockaddr_in))<0)
{
pmlog(strerror(errno));
return -1;
}
return 0;
}
/* The struct below is used to authorization; */
typedef struct _auth_bundle
{
char at_hostname[128]; /* The server's hostname; */
char at_address[16]; /* The server's IP address; */
int at_port; /* The number of port which is used to communication; */
char at_username[64]; /* Username; */
char at_password[64]; /* Password; */
char at_username_base64[96]; /* Username, after base64; */
char at_password_base64[96]; /* Password, after base64; */
} ATBD;
每次connect都超时。但是不封装能够连接上。请问如何解决?
作者: leycn 发布时间: 2010-10-17
代码:
/* TCP Socket functions; */
int tcp_init()
{
return socket(PF_INET,SOCK_STREAM,0);
}
int tcp_connect(int st,ATBD* info)
{
struct sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_port=htons(info->at_port);
sa.sin_addr.s_addr=inet_addr(info->at_address);
if(connect(st,(struct sockaddr*)&sa,sizeof(struct sockaddr_in))<0)
{
pmlog(strerror(errno));
return -1;
}
return 0;
}
/* The struct below is used to authorization; */
typedef struct _auth_bundle
{
char at_hostname[128]; /* The server's hostname; */
char at_address[16]; /* The server's IP address; */
int at_port; /* The number of port which is used to communication; */
char at_username[64]; /* Username; */
char at_password[64]; /* Password; */
char at_username_base64[96]; /* Username, after base64; */
char at_password_base64[96]; /* Password, after base64; */
} ATBD;
int tcp_init()
{
return socket(PF_INET,SOCK_STREAM,0);
}
int tcp_connect(int st,ATBD* info)
{
struct sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_port=htons(info->at_port);
sa.sin_addr.s_addr=inet_addr(info->at_address);
if(connect(st,(struct sockaddr*)&sa,sizeof(struct sockaddr_in))<0)
{
pmlog(strerror(errno));
return -1;
}
return 0;
}
/* The struct below is used to authorization; */
typedef struct _auth_bundle
{
char at_hostname[128]; /* The server's hostname; */
char at_address[16]; /* The server's IP address; */
int at_port; /* The number of port which is used to communication; */
char at_username[64]; /* Username; */
char at_password[64]; /* Password; */
char at_username_base64[96]; /* Username, after base64; */
char at_password_base64[96]; /* Password, after base64; */
} ATBD;
每次connect都超时。但是不封装能够连接上。请问如何解决?
作者: leycn 发布时间: 2010-10-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28