]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/otherlibs/win32unix/connect.c
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / otherlibs / win32unix / connect.c
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*  Xavier Leroy and Pascal Cuoq, projet Cristal, INRIA Rocquencourt   */
6 /*                                                                     */
7 /*  Copyright 1996 Institut National de Recherche en Informatique et   */
8 /*  en Automatique.  All rights reserved.  This file is distributed    */
9 /*  under the terms of the GNU Library General Public License, with    */
10 /*  the special exception on linking described in file ../../LICENSE.  */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: connect.c 7697 2006-10-18 08:26:54Z xleroy $ */
15
16 #include <mlvalues.h>
17 #include <signals.h>
18 #include "unixsupport.h"
19 #include "socketaddr.h"
20
21 CAMLprim value unix_connect(socket, address)
22      value socket, address;
23 {
24   SOCKET s = Socket_val(socket);
25   union sock_addr_union addr;
26   socklen_param_type addr_len;
27   DWORD err = 0;
28
29   get_sockaddr(address, &addr, &addr_len);
30   enter_blocking_section();
31   if (connect(s, &addr.s_gen, addr_len) == -1)
32     err = WSAGetLastError();
33   leave_blocking_section();
34   if (err) {
35     win32_maperr(err);
36     uerror("connect", Nothing);
37   }
38   return Val_unit;
39 }