当前位置: 技术问答>linux和unix
哪位给看一下 为什么连接失败 errno=111 connect 调用失败(这是客户端已tcp方式连接)
来源: 互联网 发布时间:2015-10-30
本文导语: #include #include #include #include #include #include int main() { int servers,clients; int addrsize,i; char buffer[100]; struct sockaddr_in myadress,clientaddr; //socket serversocket; myadress.sin_family=AF_INET; myadress.sin_port=htonl(8880); myadress.si...
#include
#include
#include
#include
#include
#include
int main()
{
int servers,clients;
int addrsize,i;
char buffer[100];
struct sockaddr_in myadress,clientaddr;
//socket serversocket;
myadress.sin_family=AF_INET;
myadress.sin_port=htonl(8880);
myadress.sin_addr.s_addr=inet_addr("192.168.5.23");//inet_addr
clients=socket(AF_INET,SOCK_STREAM,0);
bzero(&myadress.sin_zero,sizeof (myadress.sin_zero));
addrsize=sizeof(myadress);
if ((i=connect(clients,&myadress, addrsize))
#include
#include
#include
#include
#include
int main()
{
int servers,clients;
int addrsize,i;
char buffer[100];
struct sockaddr_in myadress,clientaddr;
//socket serversocket;
myadress.sin_family=AF_INET;
myadress.sin_port=htonl(8880);
myadress.sin_addr.s_addr=inet_addr("192.168.5.23");//inet_addr
clients=socket(AF_INET,SOCK_STREAM,0);
bzero(&myadress.sin_zero,sizeof (myadress.sin_zero));
addrsize=sizeof(myadress);
if ((i=connect(clients,&myadress, addrsize))