#151768 - ThomasS - Tue Mar 04, 2008 8:35 pm
Hi,
I want to port enet to the DS to have a way for reliable UDP messaging, but I'm having a problem in the enet_socket_send / receive functions:
In the win32 implementation, WSASendTo / WSARecvFrom is used, and in the unix implementation sendmsg and recvmsg. They are not supported by dsWifi.
So, as my DS implementation has to be compatible to the windows / linux implementations, do you know a standard implementation of sendmsg / recvmsg I could use for this? I really don't know where to look for it ...
To make this post look more interesting :-p, here's the original unix implemenation of enet_socket_send:
_________________
<dsFont> <Game Collection>
I want to port enet to the DS to have a way for reliable UDP messaging, but I'm having a problem in the enet_socket_send / receive functions:
In the win32 implementation, WSASendTo / WSARecvFrom is used, and in the unix implementation sendmsg and recvmsg. They are not supported by dsWifi.
So, as my DS implementation has to be compatible to the windows / linux implementations, do you know a standard implementation of sendmsg / recvmsg I could use for this? I really don't know where to look for it ...
To make this post look more interesting :-p, here's the original unix implemenation of enet_socket_send:
Code: |
int
enet_socket_send (ENetSocket socket, const ENetAddress * address, const ENetBuffer * buffers, size_t bufferCount) { struct msghdr msgHdr; struct sockaddr_in sin; int sentLength; memset (& msgHdr, 0, sizeof (struct msghdr)); if (address != NULL) { sin.sin_family = AF_INET; sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; msgHdr.msg_name = & sin; msgHdr.msg_namelen = sizeof (struct sockaddr_in); } msgHdr.msg_iov = (struct iovec *) buffers; msgHdr.msg_iovlen = bufferCount; sentLength = sendmsg (socket, & msgHdr, MSG_NOSIGNAL); if (sentLength == -1) { if (errno == EWOULDBLOCK) return 0; return -1; } return sentLength; } |
_________________
<dsFont> <Game Collection>