Home > other >  Socket migration android why kaka, even don't get to the Internet and death
Socket migration android why kaka, even don't get to the Internet and death

Time:09-24

Bool socketNet: : Connect (const char * IP, short port)
{

# ifdef WIN32
WSADATA Ws.
If (WSAStartup (MAKEWORD (2, 2), & amp; Ws)!=0)
{
return false;
}
# the else
# endif
_connet=socket (AF_INET SOCK_STREAM, 0).
If (_connet==INVALID_SOCKET)
return false;

Struct sockaddr_in addr.
Addr. Sin_family=AF_INET;
Addr. Sin_port=htons (port);
# ifdef WIN32
Addr. Sin_addr. S_un. S_addr=inet_addr (IP);
# the else
//addr. Sin_addr. S_addr=inet_addr (IP);
Inet_pton (AF_INET, IP, & amp; Addr. Sin_addr);
# endif
Int ret=connect (_connet, (struct sockaddr *) & amp; Addr, sizeof (addr));
If (ret!=0)
{
Closesocket (_connet);
return false;
}
}

CodePudding user response:

Don't see what problem,

CodePudding user response:

Android. Mk to modify what? Android permission thank you also added a anyone post code
  • Related