1 /* Copyright (C) 1996,1997,1998 Free Software Foundation, Inc.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16 * Boston, MA 02111-1307 USA
18 * As a special exception, the Free Software Foundation gives permission
19 * for additional uses of the text contained in its release of GUILE.
21 * The exception is that, if you link the GUILE library with other files
22 * to produce an executable, this does not by itself cause the
23 * resulting executable to be covered by the GNU General Public License.
24 * Your use of that executable is in no way restricted on account of
25 * linking the GUILE library code into it.
27 * This exception does not however invalidate any other reasons why
28 * the executable file might be covered by the GNU General Public License.
30 * This exception applies only to the code released by the
31 * Free Software Foundation under the name GUILE. If you copy
32 * code from other Free Software Foundation releases into a copy of
33 * GUILE, as the General Public License permits, the exception does
34 * not apply to the code that you add in this way. To avoid misleading
35 * anyone as to the status of such modified files, you must delete
36 * this exception notice from them.
38 * If you write modifications of your own for GUILE, it is your choice
39 * whether to permit this exception to apply to your modifications.
40 * If you do not wish that, delete this exception notice. */
58 #include <sys/types.h>
59 #include <sys/socket.h>
60 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
63 #include <netinet/in.h>
65 #include <arpa/inet.h>
69 SCM_SYMBOL (sym_socket
, "socket");
70 static SCM scm_sock_fd_to_port
SCM_P ((int fd
, const char *proc
));
73 scm_sock_fd_to_port (fd
, proc
)
81 result
= scm_fdes_to_port (fd
, "r+0", sym_socket
);
85 SCM_PROC (s_socket
, "socket", 3, 0, 0, scm_socket
);
88 scm_socket (family
, style
, proto
)
96 SCM_ASSERT (SCM_INUMP (family
), family
, SCM_ARG1
, s_socket
);
97 SCM_ASSERT (SCM_INUMP (style
), style
, SCM_ARG2
, s_socket
);
98 SCM_ASSERT (SCM_INUMP (proto
), proto
, SCM_ARG3
, s_socket
);
99 fd
= socket (SCM_INUM (family
), SCM_INUM (style
), SCM_INUM (proto
));
100 result
= scm_sock_fd_to_port (fd
, s_socket
);
106 #ifdef HAVE_SOCKETPAIR
107 SCM_PROC (s_socketpair
, "socketpair", 3, 0, 0, scm_socketpair
);
110 scm_socketpair (family
, style
, proto
)
120 SCM_ASSERT (SCM_INUMP (family
), family
, SCM_ARG1
, s_socketpair
);
121 SCM_ASSERT (SCM_INUMP (style
), style
, SCM_ARG2
, s_socketpair
);
122 SCM_ASSERT (SCM_INUMP (proto
), proto
, SCM_ARG3
, s_socketpair
);
124 fam
= SCM_INUM (family
);
126 if (socketpair (fam
, SCM_INUM (style
), SCM_INUM (proto
), fd
) == -1)
127 scm_syserror (s_socketpair
);
129 a
= scm_sock_fd_to_port (fd
[0], s_socketpair
);
130 b
= scm_sock_fd_to_port (fd
[1], s_socketpair
);
131 return scm_cons (a
, b
);
135 SCM_PROC (s_getsockopt
, "getsockopt", 3, 0, 0, scm_getsockopt
);
138 scm_getsockopt (sock
, level
, optname
)
145 #ifdef HAVE_STRUCT_LINGER
146 char optval
[sizeof (struct linger
)];
148 char optval
[sizeof (scm_sizet
)];
153 #ifdef HAVE_STRUCT_LINGER
154 optlen
= (int) sizeof (struct linger
);
156 optlen
= (int) sizeof (scm_sizet
);
159 sock
= SCM_COERCE_OUTPORT (sock
);
160 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
,
162 SCM_ASSERT (SCM_INUMP (level
), level
, SCM_ARG2
, s_getsockopt
);
163 SCM_ASSERT (SCM_INUMP (optname
), optname
, SCM_ARG3
, s_getsockopt
);
165 fd
= SCM_FPORT_FDES (sock
);
166 ilevel
= SCM_INUM (level
);
167 ioptname
= SCM_INUM (optname
);
168 if (getsockopt (fd
, ilevel
, ioptname
, (void *) optval
, &optlen
) == -1)
169 scm_syserror (s_getsockopt
);
172 if (ilevel
== SOL_SOCKET
&& ioptname
== SO_LINGER
)
174 #ifdef HAVE_STRUCT_LINGER
175 struct linger
*ling
= (struct linger
*) optval
;
176 return scm_cons (SCM_MAKINUM (ling
->l_onoff
),
177 SCM_MAKINUM (ling
->l_linger
));
179 scm_sizet
*ling
= (scm_sizet
*) optval
;
180 return scm_cons (SCM_MAKINUM (*ling
),
186 if (ilevel
== SOL_SOCKET
&& ioptname
== SO_SNDBUF
)
188 scm_sizet
*bufsize
= (scm_sizet
*) optval
;
189 return SCM_MAKINUM (*bufsize
);
193 if (ilevel
== SOL_SOCKET
&& ioptname
== SO_RCVBUF
)
195 scm_sizet
*bufsize
= (scm_sizet
*) optval
;
196 return SCM_MAKINUM (*bufsize
);
199 return SCM_MAKINUM (*(int *) optval
);
202 SCM_PROC (s_setsockopt
, "setsockopt", 4, 0, 0, scm_setsockopt
);
205 scm_setsockopt (sock
, level
, optname
, value
)
213 #ifdef HAVE_STRUCT_LINGER
214 char optval
[sizeof (struct linger
)]; /* Biggest option :-( */
216 char optval
[sizeof (scm_sizet
)];
218 int ilevel
, ioptname
;
219 sock
= SCM_COERCE_OUTPORT (sock
);
220 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
,
222 SCM_ASSERT (SCM_INUMP (level
), level
, SCM_ARG2
, s_setsockopt
);
223 SCM_ASSERT (SCM_INUMP (optname
), optname
, SCM_ARG3
, s_setsockopt
);
224 fd
= SCM_FPORT_FDES (sock
);
225 ilevel
= SCM_INUM (level
);
226 ioptname
= SCM_INUM (optname
);
229 else if (ilevel
== SOL_SOCKET
&& ioptname
== SO_LINGER
)
231 #ifdef HAVE_STRUCT_LINGER
233 SCM_ASSERT (SCM_NIMP (value
) && SCM_CONSP (value
)
234 && SCM_INUMP (SCM_CAR (value
))
235 && SCM_INUMP (SCM_CDR (value
)),
236 value
, SCM_ARG4
, s_setsockopt
);
237 ling
.l_onoff
= SCM_INUM (SCM_CAR (value
));
238 ling
.l_linger
= SCM_INUM (SCM_CDR (value
));
239 optlen
= (int) sizeof (struct linger
);
240 memcpy (optval
, (void *) &ling
, optlen
);
243 SCM_ASSERT (SCM_NIMP (value
) && SCM_CONSP (value
)
244 && SCM_INUMP (SCM_CAR (value
))
245 && SCM_INUMP (SCM_CDR (value
)),
246 value
, SCM_ARG4
, s_setsockopt
);
247 ling
= SCM_INUM (SCM_CAR (value
));
248 optlen
= (int) sizeof (scm_sizet
);
249 (*(scm_sizet
*) optval
) = (scm_sizet
) SCM_INUM (value
);
254 else if (ilevel
== SOL_SOCKET
&& ioptname
== SO_SNDBUF
)
256 SCM_ASSERT (SCM_INUMP (value
), value
, SCM_ARG4
, s_setsockopt
);
257 optlen
= (int) sizeof (scm_sizet
);
258 (*(scm_sizet
*) optval
) = (scm_sizet
) SCM_INUM (value
);
262 else if (ilevel
== SOL_SOCKET
&& ioptname
== SO_RCVBUF
)
264 SCM_ASSERT (SCM_INUMP (value
), value
, SCM_ARG4
, s_setsockopt
);
265 optlen
= (int) sizeof (scm_sizet
);
266 (*(scm_sizet
*) optval
) = (scm_sizet
) SCM_INUM (value
);
271 /* Most options just take an int. */
272 SCM_ASSERT (SCM_INUMP (value
), value
, SCM_ARG4
, s_setsockopt
);
273 optlen
= (int) sizeof (int);
274 (*(int *) optval
) = (int) SCM_INUM (value
);
276 if (setsockopt (fd
, ilevel
, ioptname
, (void *) optval
, optlen
) == -1)
277 scm_syserror (s_setsockopt
);
278 return SCM_UNSPECIFIED
;
281 SCM_PROC (s_shutdown
, "shutdown", 2, 0, 0, scm_shutdown
);
284 scm_shutdown (sock
, how
)
289 sock
= SCM_COERCE_OUTPORT (sock
);
290 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
,
292 SCM_ASSERT (SCM_INUMP (how
) && 0 <= SCM_INUM (how
) && 2 >= SCM_INUM (how
),
293 how
, SCM_ARG2
, s_shutdown
);
294 fd
= SCM_FPORT_FDES (sock
);
295 if (shutdown (fd
, SCM_INUM (how
)) == -1)
296 scm_syserror (s_shutdown
);
297 return SCM_UNSPECIFIED
;
300 /* convert fam/address/args into a sockaddr of the appropriate type.
301 args is modified by removing the arguments actually used.
302 which_arg and proc are used when reporting errors:
303 which_arg is the position of address in the original argument list.
304 proc is the name of the original procedure.
305 size returns the size of the structure allocated. */
308 static struct sockaddr
* scm_fill_sockaddr
SCM_P ((int fam
, SCM address
, SCM
*args
, int which_arg
, const char *proc
, scm_sizet
*size
));
310 static struct sockaddr
*
311 scm_fill_sockaddr (fam
, address
, args
, which_arg
, proc
, size
)
324 struct sockaddr_in
*soka
;
326 soka
= (struct sockaddr_in
*)
327 scm_must_malloc (sizeof (struct sockaddr_in
), proc
);
328 soka
->sin_family
= AF_INET
;
329 soka
->sin_addr
.s_addr
=
330 htonl (scm_num2ulong (address
, (char *) which_arg
, proc
));
331 SCM_ASSERT (SCM_NIMP (*args
) && SCM_CONSP (*args
), *args
,
332 which_arg
+ 1, proc
);
333 isport
= SCM_CAR (*args
);
334 *args
= SCM_CDR (*args
);
335 SCM_ASSERT (SCM_INUMP (isport
), isport
, which_arg
+ 1, proc
);
336 soka
->sin_port
= htons (SCM_INUM (isport
));
337 *size
= sizeof (struct sockaddr_in
);
338 return (struct sockaddr
*) soka
;
340 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
343 struct sockaddr_un
*soka
;
345 soka
= (struct sockaddr_un
*)
346 scm_must_malloc (sizeof (struct sockaddr_un
), proc
);
347 soka
->sun_family
= AF_UNIX
;
348 SCM_ASSERT (SCM_NIMP (address
) && SCM_ROSTRINGP (address
), address
,
350 memcpy (soka
->sun_path
, SCM_ROCHARS (address
),
351 1 + SCM_ROLENGTH (address
));
352 *size
= sizeof (struct sockaddr_un
);
353 return (struct sockaddr
*) soka
;
357 scm_out_of_range (proc
, SCM_MAKINUM (fam
));
361 SCM_PROC (s_connect
, "connect", 3, 0, 1, scm_connect
);
364 scm_connect (sock
, fam
, address
, args
)
372 struct sockaddr
*soka
;
375 sock
= SCM_COERCE_OUTPORT (sock
);
376 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_connect
);
377 SCM_ASSERT (SCM_INUMP (fam
), fam
, SCM_ARG2
, s_connect
);
378 fd
= SCM_FPORT_FDES (sock
);
379 soka
= scm_fill_sockaddr (SCM_INUM (fam
), address
, &args
, 3, s_connect
, &size
);
380 if (connect (fd
, soka
, size
) == -1)
381 scm_syserror (s_connect
);
382 scm_must_free ((char *) soka
);
383 return SCM_UNSPECIFIED
;
386 SCM_PROC (s_bind
, "bind", 3, 0, 1, scm_bind
);
389 scm_bind (sock
, fam
, address
, args
)
396 struct sockaddr
*soka
;
400 sock
= SCM_COERCE_OUTPORT (sock
);
401 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_bind
);
402 SCM_ASSERT (SCM_INUMP (fam
), fam
, SCM_ARG2
, s_bind
);
403 soka
= scm_fill_sockaddr (SCM_INUM (fam
), address
, &args
, 3, s_bind
, &size
);
404 fd
= SCM_FPORT_FDES (sock
);
405 rv
= bind (fd
, soka
, size
);
407 scm_syserror (s_bind
);
408 scm_must_free ((char *) soka
);
409 return SCM_UNSPECIFIED
;
412 SCM_PROC (s_listen
, "listen", 2, 0, 0, scm_listen
);
415 scm_listen (sock
, backlog
)
420 sock
= SCM_COERCE_OUTPORT (sock
);
421 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_listen
);
422 SCM_ASSERT (SCM_INUMP (backlog
), backlog
, SCM_ARG2
, s_listen
);
423 fd
= SCM_FPORT_FDES (sock
);
424 if (listen (fd
, SCM_INUM (backlog
)) == -1)
425 scm_syserror (s_listen
);
426 return SCM_UNSPECIFIED
;
429 /* Put the components of a sockaddr into a new SCM vector. */
431 static SCM scm_addr_vector
SCM_P ((struct sockaddr
*address
, const char *proc
));
434 scm_addr_vector (address
, proc
)
435 struct sockaddr
*address
;
438 short int fam
= address
->sa_family
;
441 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
444 struct sockaddr_un
*nad
= (struct sockaddr_un
*) address
;
445 result
= scm_make_vector (SCM_MAKINUM (2), SCM_UNSPECIFIED
);
446 ve
= SCM_VELTS (result
);
447 ve
[0] = scm_ulong2num ((unsigned long) fam
);
448 ve
[1] = scm_makfromstr (nad
->sun_path
,
449 (scm_sizet
) strlen (nad
->sun_path
), 0);
455 struct sockaddr_in
*nad
= (struct sockaddr_in
*) address
;
456 result
= scm_make_vector (SCM_MAKINUM (3), SCM_UNSPECIFIED
);
457 ve
= SCM_VELTS (result
);
458 ve
[0] = scm_ulong2num ((unsigned long) fam
);
459 ve
[1] = scm_ulong2num (ntohl (nad
->sin_addr
.s_addr
));
460 ve
[2] = scm_ulong2num ((unsigned long) ntohs (nad
->sin_port
));
463 scm_misc_error (proc
, "Unrecognised address family: %s",
464 scm_listify (SCM_MAKINUM (fam
), SCM_UNDEFINED
));
469 /* Allocate a buffer large enough to hold any sockaddr type. */
470 static char *scm_addr_buffer
;
471 static int scm_addr_buffer_size
;
473 static void scm_init_addr_buffer
SCM_P ((void));
476 scm_init_addr_buffer ()
478 scm_addr_buffer_size
=
479 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
480 (int) sizeof (struct sockaddr_un
)
485 if (sizeof (struct sockaddr_in
) > scm_addr_buffer_size
)
486 scm_addr_buffer_size
= (int) sizeof (struct sockaddr_in
);
487 scm_addr_buffer
= scm_must_malloc (scm_addr_buffer_size
, "address buffer");
490 SCM_PROC (s_accept
, "accept", 1, 0, 0, scm_accept
);
502 sock
= SCM_COERCE_OUTPORT (sock
);
503 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_accept
);
504 fd
= SCM_FPORT_FDES (sock
);
505 tmp_size
= scm_addr_buffer_size
;
506 newfd
= accept (fd
, (struct sockaddr
*) scm_addr_buffer
, &tmp_size
);
507 newsock
= scm_sock_fd_to_port (newfd
, s_accept
);
509 address
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_accept
);
511 address
= SCM_BOOL_F
;
513 return scm_cons (newsock
, address
);
516 SCM_PROC (s_getsockname
, "getsockname", 1, 0, 0, scm_getsockname
);
519 scm_getsockname (sock
)
525 sock
= SCM_COERCE_OUTPORT (sock
);
526 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_getsockname
);
527 fd
= SCM_FPORT_FDES (sock
);
528 tmp_size
= scm_addr_buffer_size
;
529 if (getsockname (fd
, (struct sockaddr
*) scm_addr_buffer
, &tmp_size
) == -1)
530 scm_syserror (s_getsockname
);
532 result
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_getsockname
);
538 SCM_PROC (s_getpeername
, "getpeername", 1, 0, 0, scm_getpeername
);
541 scm_getpeername (sock
)
547 sock
= SCM_COERCE_OUTPORT (sock
);
548 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_getpeername
);
549 fd
= SCM_FPORT_FDES (sock
);
550 tmp_size
= scm_addr_buffer_size
;
551 if (getpeername (fd
, (struct sockaddr
*) scm_addr_buffer
, &tmp_size
) == -1)
552 scm_syserror (s_getpeername
);
554 result
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_getpeername
);
560 SCM_PROC (s_recv
, "recv!", 2, 1, 0, scm_recv
);
563 scm_recv (sock
, buf
, flags
)
572 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_recv
);
573 SCM_ASSERT (SCM_NIMP (buf
) && SCM_STRINGP (buf
), buf
, SCM_ARG2
, s_recv
);
575 fd
= SCM_FPORT_FDES (sock
);
576 if (SCM_UNBNDP (flags
))
579 flg
= scm_num2ulong (flags
, (char *) SCM_ARG3
, s_recv
);
581 SCM_SYSCALL (rv
= recv (fd
, SCM_CHARS (buf
), SCM_LENGTH (buf
), flg
));
583 scm_syserror (s_recv
);
585 return SCM_MAKINUM (rv
);
588 SCM_PROC (s_send
, "send", 2, 1, 0, scm_send
);
591 scm_send (sock
, message
, flags
)
600 sock
= SCM_COERCE_OUTPORT (sock
);
601 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
, s_send
);
602 SCM_ASSERT (SCM_NIMP (message
) && SCM_ROSTRINGP (message
), message
, SCM_ARG2
, s_send
);
604 fd
= SCM_FPORT_FDES (sock
);
605 if (SCM_UNBNDP (flags
))
608 flg
= scm_num2ulong (flags
, (char *) SCM_ARG3
, s_send
);
610 SCM_SYSCALL (rv
= send (fd
, SCM_ROCHARS (message
), SCM_ROLENGTH (message
), flg
));
612 scm_syserror (s_send
);
613 return SCM_MAKINUM (rv
);
616 SCM_PROC (s_recvfrom
, "recvfrom!", 2, 3, 0, scm_recvfrom
);
619 scm_recvfrom (sock
, buf
, flags
, start
, end
)
634 SCM_ASSERT (SCM_NIMP (sock
) && SCM_OPFPORTP (sock
), sock
, SCM_ARG1
,
636 SCM_ASSERT (SCM_NIMP (buf
) && SCM_STRINGP (buf
), buf
, SCM_ARG2
, s_recvfrom
);
637 cend
= SCM_LENGTH (buf
);
639 if (SCM_UNBNDP (flags
))
643 flg
= scm_num2ulong (flags
, (char *) SCM_ARG3
, s_recvfrom
);
645 if (!SCM_UNBNDP (start
))
647 offset
= (int) scm_num2long (start
,
648 (char *) SCM_ARG4
, s_recvfrom
);
650 if (offset
< 0 || offset
>= cend
)
651 scm_out_of_range (s_recvfrom
, start
);
653 if (!SCM_UNBNDP (end
))
655 int tend
= (int) scm_num2long (end
,
656 (char *) SCM_ARG5
, s_recvfrom
);
658 if (tend
<= offset
|| tend
> cend
)
659 scm_out_of_range (s_recvfrom
, end
);
666 fd
= SCM_FPORT_FDES (sock
);
668 tmp_size
= scm_addr_buffer_size
;
669 SCM_SYSCALL (rv
= recvfrom (fd
, SCM_CHARS (buf
) + offset
,
671 (struct sockaddr
*) scm_addr_buffer
,
674 scm_syserror (s_recvfrom
);
676 address
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_recvfrom
);
678 address
= SCM_BOOL_F
;
680 return scm_cons (SCM_MAKINUM (rv
), address
);
683 SCM_PROC (s_sendto
, "sendto", 4, 0, 1, scm_sendto
);
686 scm_sendto (sock
, message
, fam
, address
, args_and_flags
)
696 struct sockaddr
*soka
;
700 sock
= SCM_COERCE_OUTPORT (sock
);
701 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_sendto
);
702 SCM_ASSERT (SCM_NIMP (message
) && SCM_ROSTRINGP (message
), message
,
704 SCM_ASSERT (SCM_INUMP (fam
), fam
, SCM_ARG3
, s_sendto
);
705 fd
= SCM_FPORT_FDES (sock
);
706 soka
= scm_fill_sockaddr (SCM_INUM (fam
), address
, &args_and_flags
, 4,
708 if (SCM_NULLP (args_and_flags
))
712 SCM_ASSERT (SCM_NIMP (args_and_flags
) && SCM_CONSP (args_and_flags
),
713 args_and_flags
, SCM_ARG5
, s_sendto
);
714 flg
= scm_num2ulong (SCM_CAR (args_and_flags
), (char *) SCM_ARG5
, s_sendto
);
716 SCM_SYSCALL (rv
= sendto (fd
, SCM_ROCHARS (message
), SCM_ROLENGTH (message
),
719 scm_must_free ((char *) soka
);
722 scm_syserror (s_sendto
);
723 return SCM_MAKINUM (rv
);
731 /* protocol families. */
733 scm_sysintern ("AF_UNSPEC", SCM_MAKINUM (AF_UNSPEC
));
736 scm_sysintern ("AF_UNIX", SCM_MAKINUM (AF_UNIX
));
739 scm_sysintern ("AF_INET", SCM_MAKINUM (AF_INET
));
743 scm_sysintern ("PF_UNSPEC", SCM_MAKINUM (PF_UNSPEC
));
746 scm_sysintern ("PF_UNIX", SCM_MAKINUM (PF_UNIX
));
749 scm_sysintern ("PF_INET", SCM_MAKINUM (PF_INET
));
754 scm_sysintern ("SOCK_STREAM", SCM_MAKINUM (SOCK_STREAM
));
757 scm_sysintern ("SOCK_DGRAM", SCM_MAKINUM (SOCK_DGRAM
));
760 scm_sysintern ("SOCK_RAW", SCM_MAKINUM (SOCK_RAW
));
763 /* setsockopt level. */
765 scm_sysintern ("SOL_SOCKET", SCM_MAKINUM (SOL_SOCKET
));
768 scm_sysintern ("SOL_IP", SCM_MAKINUM (SOL_IP
));
771 scm_sysintern ("SOL_TCP", SCM_MAKINUM (SOL_TCP
));
774 scm_sysintern ("SOL_UDP", SCM_MAKINUM (SOL_UDP
));
777 /* setsockopt names. */
779 scm_sysintern ("SO_DEBUG", SCM_MAKINUM (SO_DEBUG
));
782 scm_sysintern ("SO_REUSEADDR", SCM_MAKINUM (SO_REUSEADDR
));
785 scm_sysintern ("SO_STYLE", SCM_MAKINUM (SO_STYLE
));
788 scm_sysintern ("SO_TYPE", SCM_MAKINUM (SO_TYPE
));
791 scm_sysintern ("SO_ERROR", SCM_MAKINUM (SO_ERROR
));
794 scm_sysintern ("SO_DONTROUTE", SCM_MAKINUM (SO_DONTROUTE
));
797 scm_sysintern ("SO_BROADCAST", SCM_MAKINUM (SO_BROADCAST
));
800 scm_sysintern ("SO_SNDBUF", SCM_MAKINUM (SO_SNDBUF
));
803 scm_sysintern ("SO_RCVBUF", SCM_MAKINUM (SO_RCVBUF
));
806 scm_sysintern ("SO_KEEPALIVE", SCM_MAKINUM (SO_KEEPALIVE
));
809 scm_sysintern ("SO_OOBINLINE", SCM_MAKINUM (SO_OOBINLINE
));
812 scm_sysintern ("SO_NO_CHECK", SCM_MAKINUM (SO_NO_CHECK
));
815 scm_sysintern ("SO_PRIORITY", SCM_MAKINUM (SO_PRIORITY
));
818 scm_sysintern ("SO_LINGER", SCM_MAKINUM (SO_LINGER
));
821 /* recv/send options. */
823 scm_sysintern ("MSG_OOB", SCM_MAKINUM (MSG_OOB
));
826 scm_sysintern ("MSG_PEEK", SCM_MAKINUM (MSG_PEEK
));
829 scm_sysintern ("MSG_DONTROUTE", SCM_MAKINUM (MSG_DONTROUTE
));
832 scm_add_feature ("socket");
833 scm_init_addr_buffer ();