2 Copyright © 2000-2010, The AROS Development Team. All rights reserved.
9 #include <proto/exec.h>
10 #include <sys/errno.h>
12 #include "bsdsocket_intern.h"
13 #include "bsdsocket_util.h"
14 #include "socket_intern.h"
16 /*****************************************************************************
23 AROS_LHA(int, domain
, D0
),
24 AROS_LHA(int, type
, D1
),
25 AROS_LHA(int, protocol
, D2
),
28 struct TaskBase
*, taskBase
, 12, BSDSocket
)
48 *****************************************************************************/
52 struct bsdsocketBase
*SocketBase
= taskBase
->glob
;
57 D(bug("[bsdsocket] socket(%d, %d, %d)\n", domain
, type
, protocol
));
59 s
= GetFreeFD(taskBase
);
63 sd
= AllocPooled(taskBase
->pool
, sizeof(struct Socket
));
66 SetError(ENOMEM
, taskBase
);
74 sd
->s
= WSsocket(domain
, type
, protocol
);
76 err
= WSAGetLastError();
79 /* This implies setting the socket to non-blocking mode, so no ioctlsocket() is needed */
80 err
= WSAEventSelect(sd
->s
, SocketBase
->ctl
->SocketEvent
, WS_FD_READ
|WS_FD_WRITE
|WS_FD_OOB
|WS_FD_ACCEPT
|WS_FD_CONNECT
|WS_FD_CLOSE
);
83 err
= WSAGetLastError();
93 FreePooled(taskBase
->pool
, sd
, sizeof(struct Socket
));
94 SetError(err
- WSABASEERR
, taskBase
);
98 AddTail((struct List
*)&SocketBase
->socks
, (struct Node
*)sd
);
99 taskBase
->dTable
[s
] = sd
;
101 D(bug("[socket] Created socket %u (descriptor 0x%p, Windows socket %d)\n", s
, sd
, sd
->s
));