Sys.Signals module for a Variant type of signals (and a set_signal function that...
[ocaml.git] / otherlibs / unix / getpeername.c
blob0431e9a33c0b449e1ea21365b133455d8a51c76e
1 /***********************************************************************/
2 /* */
3 /* Objective Caml */
4 /* */
5 /* Xavier Leroy, 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 /***********************************************************************/
14 /* $Id$ */
16 #include <fail.h>
17 #include <mlvalues.h>
18 #include "unixsupport.h"
20 #ifdef HAS_SOCKETS
22 #include "socketaddr.h"
24 CAMLprim value unix_getpeername(value sock)
26 int retcode;
27 union sock_addr_union addr;
28 socklen_param_type addr_len;
30 addr_len = sizeof(addr);
31 retcode = getpeername(Int_val(sock), &addr.s_gen, &addr_len);
32 if (retcode == -1) uerror("getpeername", Nothing);
33 return alloc_sockaddr(&addr, addr_len, -1);
36 #else
38 CAMLprim value unix_getpeername(value sock)
39 { invalid_argument("getpeername not implemented"); }
41 #endif