Merge pull request #42 from d3m3vilurr/vita-getaddrinfo

vita: Apply getaddrinfo
This commit is contained in:
Cameron Gutman 2019-08-13 17:47:03 -07:00 committed by GitHub
commit 4daf496bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 31 deletions

View File

@ -286,7 +286,6 @@ int enableNoDelay(SOCKET s) {
int resolveHostName(const char* host, int family, int tcpTestPort, struct sockaddr_storage* addr, SOCKADDR_LEN* addrLen)
{
#ifndef __vita__
struct addrinfo hints, *res, *currentAddr;
int err;
@ -331,21 +330,6 @@ int resolveHostName(const char* host, int family, int tcpTestPort, struct sockad
Limelog("No working addresses found for host: %s\n", host);
freeaddrinfo(res);
return -1;
#else
struct hostent *phost = gethostbyname(host);
if (!phost) {
Limelog("gethostbyname() failed for host %s\n", host);
return -1;
}
struct sockaddr_in tmp = {0};
tmp.sin_len = sizeof(tmp);
tmp.sin_family = SCE_NET_AF_INET;
memcpy(&tmp.sin_addr, phost->h_addr, phost->h_length);
memcpy(addr, &tmp, sizeof(tmp));
*addrLen = sizeof(tmp);
return 0;
#endif
}
#ifndef __vita__

View File

@ -18,26 +18,21 @@ typedef int SOCK_RET;
typedef int SOCKADDR_LEN;
#else
#if defined(__vita__)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#ifndef __vita__
#include <netinet/tcp.h>
#else
#include <psp2/net/net.h>
#include <enet/enet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/tcp.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <signal.h>
#endif
#define ioctlsocket ioctl
#define LastSocketError() errno
@ -56,8 +51,6 @@ typedef socklen_t SOCKADDR_LEN;
#define sockaddr_in6 sockaddr_in
#define sin6_addr sin_addr
#define sin6_port sin_port
#define INET6_ADDRSTRLEN 128
#define inet_ntop sceNetInetNtop
#endif
#define LastSocketFail() ((LastSocketError() != 0) ? LastSocketError() : -1)