1996-04-12 08:57:28 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1996-04-12 08:57:28 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1996-04-12 08:57:28 -07:00
|
|
|
/* Automatique. Distributed only by permission. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include <mlvalues.h>
|
1996-09-04 07:15:31 -07:00
|
|
|
#include "unixsupport.h"
|
1996-04-12 08:57:28 -07:00
|
|
|
|
|
|
|
#ifdef HAS_SOCKETS
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
1996-10-24 09:15:25 -07:00
|
|
|
#ifndef SO_BROADCAST
|
|
|
|
#define SO_BROADCAST (-1)
|
|
|
|
#endif
|
|
|
|
#ifndef SO_OOBINLINE
|
|
|
|
#define SO_OOBINLINE (-1)
|
|
|
|
#endif
|
|
|
|
|
1996-04-12 08:57:28 -07:00
|
|
|
static int sockopt[] = {
|
|
|
|
SO_DEBUG, SO_BROADCAST, SO_REUSEADDR, SO_KEEPALIVE,
|
|
|
|
SO_DONTROUTE, SO_OOBINLINE };
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value unix_getsockopt(value socket, value option)
|
1996-04-12 08:57:28 -07:00
|
|
|
{
|
|
|
|
int optval, optsize;
|
|
|
|
optsize = sizeof(optval);
|
|
|
|
if (getsockopt(Int_val(socket), SOL_SOCKET, sockopt[Int_val(option)],
|
1996-10-01 02:46:57 -07:00
|
|
|
(void *) &optval, &optsize) == -1)
|
1996-04-12 08:57:28 -07:00
|
|
|
uerror("getsockopt", Nothing);
|
|
|
|
return Val_int(optval);
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value unix_setsockopt(value socket, value option, value status)
|
1996-04-12 08:57:28 -07:00
|
|
|
{
|
|
|
|
int optval = Int_val(status);
|
|
|
|
if (setsockopt(Int_val(socket), SOL_SOCKET, sockopt[Int_val(option)],
|
1996-10-01 02:46:57 -07:00
|
|
|
(void *) &optval, sizeof(optval)) == -1)
|
1996-04-12 08:57:28 -07:00
|
|
|
uerror("setsockopt", Nothing);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value unix_getsockopt(value socket, value option)
|
|
|
|
{ invalid_argument("getsockopt not implemented"); }
|
|
|
|
|
|
|
|
value unix_setsockopt(value socket, value option, value status)
|
|
|
|
{ invalid_argument("setsockopt not implemented"); }
|
1996-04-12 08:57:28 -07:00
|
|
|
|
|
|
|
#endif
|