2 Copyright © 2000-2010, The AROS Development Team. All rights reserved.
11 #include <proto/exec.h>
13 #include <sys/errno.h>
14 #include <sys/socket.h>
16 #include "bsdsocket_intern.h"
17 #include "bsdsocket_util.h"
18 #include "socket_intern.h"
20 /* FIXME: AROS libc has incorrect values in errno.h */
22 #define EWOULDBLOCK 35
24 /*****************************************************************************
32 AROS_LHA(const void *, msg
, A0
),
33 AROS_LHA(int, len
, D1
),
34 AROS_LHA(int, flags
, D2
),
35 AROS_LHA(const struct sockaddr
*, to
, A1
),
36 AROS_LHA(int, tolen
, D3
),
39 struct TaskBase
*, taskBase
, 12, BSDSocket
)
59 *****************************************************************************/
63 struct bsdsocketBase
*SocketBase
= taskBase
->glob
;
66 struct WSsockaddr
*sa
;
69 D(bug("[sendto] Sending %u bytes to socket %u\n", len
, s
));
70 sd
= GetSocket(s
, taskBase
);
74 D(bug("[sendto] Descriptor 0x%p, Windows socket %d\n", sd
, sd
->s
));
75 sa
= MakeSockAddr(to
, tolen
, taskBase
);
81 res
= WSsendto(sd
->s
, msg
, len
, flags
, sa
, tolen
);
83 err
= WSAGetLastError() - WSABASEERR
;
86 FreePooled(taskBase
->pool
, sa
, tolen
);
87 D(bug("[sendto] Result: %d, Error: %u\n", res
, err
));
89 /* From Windows side all sockets are asynchronous, but from AROS side
90 not all are. So if AROS socket is synchronous and Windows returned us
91 EWOULDBLOCK, we need to wait for completion */
92 if ((err
== EWOULDBLOCK
) && (!(sd
->flags
& SOF_NBIO
)))
94 D(bug("[sendto] Waiting for the completion\n"));
99 SetError(err
, taskBase
);