Flesh out socket_create some more

This commit is contained in:
twinaphex 2016-05-02 18:42:13 +02:00
parent 62508eca77
commit 18f8ded154
3 changed files with 44 additions and 10 deletions
libretro-common
netlogger.c

View File

@ -43,6 +43,12 @@ enum socket_type
SOCKET_TYPE_SEQPACKET
};
enum socket_protocol
{
SOCKET_PROTOCOL_NONE = 0,
SOCKET_PROTOCOL_UDP
};
int socket_init(void **address, uint16_t port, const char *server, enum socket_type type);
int socket_close(int fd);
@ -63,7 +69,11 @@ bool socket_bind(int fd, void *data);
int socket_connect(int fd, void *data, bool timeout_enable);
int socket_create(const char *name, enum socket_domain domain_type, enum socket_type socket_type, int protocol);
int socket_create(
const char *name,
enum socket_domain domain_type,
enum socket_type socket_type,
enum socket_protocol protocol_type);
RETRO_END_DECLS

View File

@ -217,13 +217,14 @@ int socket_connect(int fd, void *data, bool timeout_enable)
int socket_create(
const char *name,
enum socket_domain domain_type,
enum socket_type socket_type,
int protocol)
enum socket_domain domain_type,
enum socket_type socket_type,
enum socket_protocol protocol_type)
{
#ifdef VITA
int type = 0;
int domain = 0;
int type = 0;
int domain = 0;
int protocol = 0;
switch (domain_type)
{
@ -244,10 +245,22 @@ int socket_create(
/* TODO/FIXME - implement */
break;
}
switch (protocol_type)
{
case SOCKET_PROTOCOL_NONE:
protocol = 0;
break;
case SOCKET_PROTOCOL_UDP:
/* TODO/FIXME - implement */
break;
}
return sceNetSocket(name, domain, type, protocol);
#else
int type = 0;
int domain = 0;
int type = 0;
int domain = 0;
int protocol = 0;
switch (domain_type)
{
@ -268,6 +281,17 @@ int socket_create(
/* TODO/FIXME - implement */
break;
}
switch (protocol_type)
{
case SOCKET_PROTOCOL_NONE:
protocol = 0;
break;
case SOCKET_PROTOCOL_UDP:
/* TODO/FIXME - implement */
break;
}
return socket(domain, type, protocol);
#endif
}

View File

@ -67,7 +67,7 @@ static int network_interface_up(struct sockaddr_in *target, int index,
"ra_netlogger",
SOCKET_DOMAIN_INET,
SOCKET_TYPE_DATAGRAM,
0);
SOCKET_PROTOCOL_NONE);
target->sin_family = PSP2_NET_AF_INET;
target->sin_port = sceNetHtons(udp_port);
@ -108,7 +108,7 @@ static int network_interface_up(struct sockaddr_in *target, int index,
"ra_netlogger",
SOCKET_DOMAIN_INET,
SOCKET_TYPE_DATAGRAM,
0);
SOCKET_PROTOCOL_NONE);
target->sin_family = AF_INET;
target->sin_port = htons(udp_port);