1 /**************************************************************************/
2 /*                                                                        */
3 /*                                 OCaml                                  */
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.                                                    */
9 /*                                                                        */
10 /*   All rights reserved.  This file is distributed under the terms of    */
11 /*   the GNU Lesser General Public License version 2.1, with the          */
12 /*   special exception on linking described in the file LICENSE.          */
13 /*                                                                        */
14 /**************************************************************************/
15 
16 #include <caml/mlvalues.h>
17 #include <caml/signals.h>
18 #include "unixsupport.h"
19 #include "socketaddr.h"
20 
unix_connect(socket,address)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   caml_enter_blocking_section();
31   if (connect(s, &addr.s_gen, addr_len) == -1)
32     err = WSAGetLastError();
33   caml_leave_blocking_section();
34   if (err) {
35     win32_maperr(err);
36     uerror("connect", Nothing);
37   }
38   return Val_unit;
39 }
40