1 /* Copyright (C) 1996,1997 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 UNIX_DOMAIN_SOCKETS
63 #include <netinet/in.h>
65 #include <arpa/inet.h>
69 static SCM scm_sock_fd_to_port
SCM_P ((int fd
, char *proc
));
72 scm_sock_fd_to_port (fd
, proc
)
81 f
= fdopen (fd
, "r+");
84 SCM_SYSCALL (close (fd
));
89 struct scm_port_table
*pt
= scm_add_to_port_table (result
);
91 SCM_SETPTAB_ENTRY (result
, pt
);
93 SCM_SETCAR (result
, scm_tc16_fport
| scm_mode_bits ("r+0"));
94 SCM_SETSTREAM (result
, (SCM
)f
);
99 SCM_PROC (s_socket
, "socket", 3, 0, 0, scm_socket
);
102 scm_socket (family
, style
, proto
)
110 SCM_ASSERT (SCM_INUMP (family
), family
, SCM_ARG1
, s_socket
);
111 SCM_ASSERT (SCM_INUMP (style
), style
, SCM_ARG2
, s_socket
);
112 SCM_ASSERT (SCM_INUMP (proto
), proto
, SCM_ARG3
, s_socket
);
114 fd
= socket (SCM_INUM (family
), SCM_INUM (style
), SCM_INUM (proto
));
115 result
= scm_sock_fd_to_port (fd
, s_socket
);
122 #ifdef HAVE_SOCKETPAIR
123 SCM_PROC (s_socketpair
, "socketpair", 3, 0, 0, scm_socketpair
);
126 scm_socketpair (family
, style
, proto
)
136 SCM_ASSERT (SCM_INUMP (family
), family
, SCM_ARG1
, s_socketpair
);
137 SCM_ASSERT (SCM_INUMP (style
), style
, SCM_ARG2
, s_socketpair
);
138 SCM_ASSERT (SCM_INUMP (proto
), proto
, SCM_ARG3
, s_socketpair
);
140 fam
= SCM_INUM (family
);
143 if (socketpair (fam
, SCM_INUM (style
), SCM_INUM (proto
), fd
) == -1)
144 scm_syserror (s_socketpair
);
146 a
= scm_sock_fd_to_port (fd
[0], s_socketpair
);
147 b
= scm_sock_fd_to_port (fd
[1], s_socketpair
);
149 return scm_cons (a
, b
);
153 SCM_PROC (s_getsockopt
, "getsockopt", 3, 0, 0, scm_getsockopt
);
156 scm_getsockopt (sock
, level
, optname
)
163 #ifdef HAVE_STRUCT_LINGER
164 char optval
[sizeof (struct linger
)];
166 char optval
[sizeof (scm_sizet
)];
171 #ifdef HAVE_STRUCT_LINGER
172 optlen
= (int) sizeof (struct linger
);
174 optlen
= (int) sizeof (scm_sizet
);
177 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
,
179 SCM_ASSERT (SCM_INUMP (level
), level
, SCM_ARG2
, s_getsockopt
);
180 SCM_ASSERT (SCM_INUMP (optname
), optname
, SCM_ARG3
, s_getsockopt
);
182 fd
= fileno ((FILE *)SCM_STREAM (sock
));
183 ilevel
= SCM_INUM (level
);
184 ioptname
= SCM_INUM (optname
);
185 if (getsockopt (fd
, ilevel
, ioptname
, (void *) optval
, &optlen
) == -1)
186 scm_syserror (s_getsockopt
);
189 if (ilevel
== SOL_SOCKET
&& ioptname
== SO_LINGER
)
191 #ifdef HAVE_STRUCT_LINGER
192 struct linger
*ling
= (struct linger
*) optval
;
193 return scm_cons (SCM_MAKINUM (ling
->l_onoff
),
194 SCM_MAKINUM (ling
->l_linger
));
196 scm_sizet
*ling
= (scm_sizet
*) optval
;
197 return scm_cons (SCM_MAKINUM (*ling
),
203 if (ilevel
== SOL_SOCKET
&& ioptname
== SO_SNDBUF
)
205 scm_sizet
*bufsize
= (scm_sizet
*) optval
;
206 return SCM_MAKINUM (*bufsize
);
210 if (ilevel
== SOL_SOCKET
&& ioptname
== SO_RCVBUF
)
212 scm_sizet
*bufsize
= (scm_sizet
*) optval
;
213 return SCM_MAKINUM (*bufsize
);
216 return SCM_MAKINUM (*(int *) optval
);
219 SCM_PROC (s_setsockopt
, "setsockopt", 4, 0, 0, scm_setsockopt
);
222 scm_setsockopt (sock
, level
, optname
, value
)
230 #ifdef HAVE_STRUCT_LINGER
231 char optval
[sizeof (struct linger
)]; /* Biggest option :-( */
233 char optval
[sizeof (scm_sizet
)];
235 int ilevel
, ioptname
;
236 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
,
238 SCM_ASSERT (SCM_INUMP (level
), level
, SCM_ARG2
, s_setsockopt
);
239 SCM_ASSERT (SCM_INUMP (optname
), optname
, SCM_ARG3
, s_setsockopt
);
240 fd
= fileno ((FILE *)SCM_STREAM (sock
));
241 ilevel
= SCM_INUM (level
);
242 ioptname
= SCM_INUM (optname
);
245 else if (ilevel
== SOL_SOCKET
&& ioptname
== SO_LINGER
)
247 #ifdef HAVE_STRUCT_LINGER
249 SCM_ASSERT (SCM_NIMP (value
) && SCM_CONSP (value
)
250 && SCM_INUMP (SCM_CAR (value
))
251 && SCM_INUMP (SCM_CDR (value
)),
252 value
, SCM_ARG4
, s_setsockopt
);
253 ling
.l_onoff
= SCM_INUM (SCM_CAR (value
));
254 ling
.l_linger
= SCM_INUM (SCM_CDR (value
));
255 optlen
= (int) sizeof (struct linger
);
256 memcpy (optval
, (void *) &ling
, optlen
);
259 SCM_ASSERT (SCM_NIMP (value
) && SCM_CONSP (value
)
260 && SCM_INUMP (SCM_CAR (value
))
261 && SCM_INUMP (SCM_CDR (value
)),
262 value
, SCM_ARG4
, s_setsockopt
);
263 ling
= SCM_INUM (SCM_CAR (value
));
264 optlen
= (int) sizeof (scm_sizet
);
265 (*(scm_sizet
*) optval
) = (scm_sizet
) SCM_INUM (value
);
270 else if (ilevel
== SOL_SOCKET
&& ioptname
== SO_SNDBUF
)
272 SCM_ASSERT (SCM_INUMP (value
), value
, SCM_ARG4
, s_setsockopt
);
273 optlen
= (int) sizeof (scm_sizet
);
274 (*(scm_sizet
*) optval
) = (scm_sizet
) SCM_INUM (value
);
278 else if (ilevel
== SOL_SOCKET
&& ioptname
== SO_RCVBUF
)
280 SCM_ASSERT (SCM_INUMP (value
), value
, SCM_ARG4
, s_setsockopt
);
281 optlen
= (int) sizeof (scm_sizet
);
282 (*(scm_sizet
*) optval
) = (scm_sizet
) SCM_INUM (value
);
287 /* Most options just take an int. */
288 SCM_ASSERT (SCM_INUMP (value
), value
, SCM_ARG4
, s_setsockopt
);
289 optlen
= (int) sizeof (int);
290 (*(int *) optval
) = (int) SCM_INUM (value
);
292 if (setsockopt (fd
, ilevel
, ioptname
, (void *) optval
, optlen
) == -1)
293 scm_syserror (s_setsockopt
);
294 return SCM_UNSPECIFIED
;
297 SCM_PROC (s_shutdown
, "shutdown", 2, 0, 0, scm_shutdown
);
300 scm_shutdown (sock
, how
)
305 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
,
307 SCM_ASSERT (SCM_INUMP (how
) && 0 <= SCM_INUM (how
) && 2 >= SCM_INUM (how
),
308 how
, SCM_ARG2
, s_shutdown
);
309 fd
= fileno ((FILE *)SCM_STREAM (sock
));
310 if (shutdown (fd
, SCM_INUM (how
)) == -1)
311 scm_syserror (s_shutdown
);
312 return SCM_UNSPECIFIED
;
315 /* convert fam/address/args into a sockaddr of the appropriate type.
316 args is modified by removing the arguments actually used.
317 which_arg and proc are used when reporting errors:
318 which_arg is the position of address in the original argument list.
319 proc is the name of the original procedure.
320 size returns the size of the structure allocated. */
323 static struct sockaddr
* scm_fill_sockaddr
SCM_P ((int fam
, SCM address
, SCM
*args
, int which_arg
, char *proc
, scm_sizet
*size
));
325 static struct sockaddr
*
326 scm_fill_sockaddr (fam
, address
, args
, which_arg
, proc
, size
)
339 struct sockaddr_in
*soka
;
341 soka
= (struct sockaddr_in
*)
342 scm_must_malloc (sizeof (struct sockaddr_in
), proc
);
343 soka
->sin_family
= AF_INET
;
344 soka
->sin_addr
.s_addr
=
345 htonl (scm_num2ulong (address
, (char *) which_arg
, proc
));
346 SCM_ASSERT (SCM_NIMP (*args
) && SCM_CONSP (*args
), *args
,
347 which_arg
+ 1, proc
);
348 isport
= SCM_CAR (*args
);
349 *args
= SCM_CDR (*args
);
350 SCM_ASSERT (SCM_INUMP (isport
), isport
, which_arg
+ 1, proc
);
351 soka
->sin_port
= htons (SCM_INUM (isport
));
352 *size
= sizeof (struct sockaddr_in
);
353 return (struct sockaddr
*) soka
;
355 #ifdef UNIX_DOMAIN_SOCKETS
358 struct sockaddr_un
*soka
;
360 soka
= (struct sockaddr_un
*)
361 scm_must_malloc (sizeof (struct sockaddr_un
), proc
);
362 soka
->sun_family
= AF_UNIX
;
363 SCM_ASSERT (SCM_NIMP (address
) && SCM_ROSTRINGP (address
), address
,
365 memcpy (soka
->sun_path
, SCM_ROCHARS (address
),
366 1 + SCM_ROLENGTH (address
));
367 *size
= sizeof (struct sockaddr_un
);
368 return (struct sockaddr
*) soka
;
372 scm_out_of_range (proc
, SCM_MAKINUM (fam
));
376 SCM_PROC (s_connect
, "connect", 3, 0, 1, scm_connect
);
379 scm_connect (sock
, fam
, address
, args
)
387 struct sockaddr
*soka
;
390 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_connect
);
391 SCM_ASSERT (SCM_INUMP (fam
), fam
, SCM_ARG2
, s_connect
);
392 fd
= fileno ((FILE *)SCM_STREAM (sock
));
394 soka
= scm_fill_sockaddr (SCM_INUM (fam
), address
, &args
, 3, s_connect
, &size
);
395 if (connect (fd
, soka
, size
) == -1)
396 scm_syserror (s_connect
);
397 scm_must_free ((char *) soka
);
399 return SCM_UNSPECIFIED
;
402 SCM_PROC (s_bind
, "bind", 3, 0, 1, scm_bind
);
405 scm_bind (sock
, fam
, address
, args
)
412 struct sockaddr
*soka
;
416 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_bind
);
417 SCM_ASSERT (SCM_INUMP (fam
), fam
, SCM_ARG2
, s_bind
);
418 soka
= scm_fill_sockaddr (SCM_INUM (fam
), address
, &args
, 3, s_bind
, &size
);
419 fd
= fileno ((FILE *)SCM_STREAM (sock
));
420 rv
= bind (fd
, soka
, size
);
422 scm_syserror (s_bind
);
423 return SCM_UNSPECIFIED
;
426 SCM_PROC (s_listen
, "listen", 2, 0, 0, scm_listen
);
429 scm_listen (sock
, backlog
)
434 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_listen
);
435 SCM_ASSERT (SCM_INUMP (backlog
), backlog
, SCM_ARG2
, s_listen
);
436 fd
= fileno ((FILE *)SCM_STREAM (sock
));
437 if (listen (fd
, SCM_INUM (backlog
)) == -1)
438 scm_syserror (s_listen
);
439 return SCM_UNSPECIFIED
;
442 /* Put the components of a sockaddr into a new SCM vector. */
444 static SCM scm_addr_vector
SCM_P ((struct sockaddr
*address
, char *proc
));
447 scm_addr_vector (address
, proc
)
448 struct sockaddr
*address
;
451 short int fam
= address
->sa_family
;
454 #ifdef UNIX_DOMAIN_SOCKETS
457 struct sockaddr_un
*nad
= (struct sockaddr_un
*) address
;
458 result
= scm_make_vector (SCM_MAKINUM (2), SCM_UNSPECIFIED
, SCM_BOOL_F
);
459 ve
= SCM_VELTS (result
);
460 ve
[0] = scm_ulong2num ((unsigned long) fam
);
461 ve
[1] = scm_makfromstr (nad
->sun_path
,
462 (scm_sizet
) strlen (nad
->sun_path
), 0);
468 struct sockaddr_in
*nad
= (struct sockaddr_in
*) address
;
469 result
= scm_make_vector (SCM_MAKINUM (3), SCM_UNSPECIFIED
, SCM_BOOL_F
);
470 ve
= SCM_VELTS (result
);
471 ve
[0] = scm_ulong2num ((unsigned long) fam
);
472 ve
[1] = scm_ulong2num (ntohl (nad
->sin_addr
.s_addr
));
473 ve
[2] = scm_ulong2num ((unsigned long) ntohs (nad
->sin_port
));
476 scm_misc_error (proc
, "Unrecognised address family: %s",
477 scm_listify (SCM_MAKINUM (fam
), SCM_UNDEFINED
));
482 /* Allocate a buffer large enough to hold any sockaddr type. */
483 static char *scm_addr_buffer
;
484 static int scm_addr_buffer_size
;
486 static void scm_init_addr_buffer
SCM_P ((void));
489 scm_init_addr_buffer ()
491 scm_addr_buffer_size
=
492 #ifdef UNIX_DOMAIN_SOCKETS
493 (int) sizeof (struct sockaddr_un
)
498 if (sizeof (struct sockaddr_in
) > scm_addr_buffer_size
)
499 scm_addr_buffer_size
= (int) sizeof (struct sockaddr_in
);
500 scm_addr_buffer
= scm_must_malloc (scm_addr_buffer_size
, "address buffer");
503 SCM_PROC (s_accept
, "accept", 1, 0, 0, scm_accept
);
515 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_accept
);
516 fd
= fileno ((FILE *)SCM_STREAM (sock
));
518 tmp_size
= scm_addr_buffer_size
;
519 newfd
= accept (fd
, (struct sockaddr
*) scm_addr_buffer
, &tmp_size
);
520 newsock
= scm_sock_fd_to_port (newfd
, s_accept
);
522 address
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_accept
);
524 address
= SCM_BOOL_F
;
527 return scm_cons (newsock
, address
);
530 SCM_PROC (s_getsockname
, "getsockname", 1, 0, 0, scm_getsockname
);
533 scm_getsockname (sock
)
539 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_getsockname
);
540 fd
= fileno ((FILE *)SCM_STREAM (sock
));
542 tmp_size
= scm_addr_buffer_size
;
543 if (getsockname (fd
, (struct sockaddr
*) scm_addr_buffer
, &tmp_size
) == -1)
544 scm_syserror (s_getsockname
);
546 result
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_getsockname
);
553 SCM_PROC (s_getpeername
, "getpeername", 1, 0, 0, scm_getpeername
);
556 scm_getpeername (sock
)
562 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_getpeername
);
563 fd
= fileno ((FILE *)SCM_STREAM (sock
));
565 tmp_size
= scm_addr_buffer_size
;
566 if (getpeername (fd
, (struct sockaddr
*) scm_addr_buffer
, &tmp_size
) == -1)
567 scm_syserror (s_getpeername
);
569 result
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_getpeername
);
576 SCM_PROC (s_recv
, "recv!", 2, 1, 0, scm_recv
);
579 scm_recv (sock
, buf
, flags
)
588 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_recv
);
589 SCM_ASSERT (SCM_NIMP (buf
) && SCM_STRINGP (buf
), buf
, SCM_ARG2
, s_recv
);
590 fd
= fileno ((FILE *)SCM_STREAM (sock
));
592 if (SCM_UNBNDP (flags
))
595 flg
= scm_num2ulong (flags
, (char *) SCM_ARG3
, s_recv
);
597 SCM_SYSCALL (rv
= recv (fd
, SCM_CHARS (buf
), SCM_LENGTH (buf
), flg
));
599 scm_syserror (s_recv
);
601 return SCM_MAKINUM (rv
);
604 SCM_PROC (s_send
, "send", 2, 1, 0, scm_send
);
607 scm_send (sock
, message
, flags
)
616 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_send
);
617 SCM_ASSERT (SCM_NIMP (message
) && SCM_ROSTRINGP (message
), message
, SCM_ARG2
, s_send
);
618 fd
= fileno ((FILE *)SCM_STREAM (sock
));
620 if (SCM_UNBNDP (flags
))
623 flg
= scm_num2ulong (flags
, (char *) SCM_ARG3
, s_send
);
625 SCM_SYSCALL (rv
= send (fd
, SCM_ROCHARS (message
), SCM_ROLENGTH (message
), flg
));
627 scm_syserror (s_send
);
628 return SCM_MAKINUM (rv
);
631 SCM_PROC (s_recvfrom
, "recvfrom!", 2, 3, 0, scm_recvfrom
);
634 scm_recvfrom (sock
, buf
, flags
, start
, end
)
649 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
,
651 SCM_ASSERT (SCM_NIMP (buf
) && SCM_STRINGP (buf
), buf
, SCM_ARG2
, s_recvfrom
);
652 cend
= SCM_LENGTH (buf
);
654 if (SCM_UNBNDP (flags
))
658 flg
= scm_num2ulong (flags
, (char *) SCM_ARG3
, s_recvfrom
);
660 if (!SCM_UNBNDP (start
))
662 offset
= (int) scm_num2long (start
,
663 (char *) SCM_ARG4
, s_recvfrom
);
665 if (offset
< 0 || offset
>= cend
)
666 scm_out_of_range (s_recvfrom
, start
);
668 if (!SCM_UNBNDP (end
))
670 int tend
= (int) scm_num2long (end
,
671 (char *) SCM_ARG5
, s_recvfrom
);
673 if (tend
<= offset
|| tend
> cend
)
674 scm_out_of_range (s_recvfrom
, end
);
681 fd
= fileno ((FILE *)SCM_STREAM (sock
));
683 tmp_size
= scm_addr_buffer_size
;
684 SCM_SYSCALL (rv
= recvfrom (fd
, SCM_CHARS (buf
) + offset
,
686 (struct sockaddr
*) scm_addr_buffer
,
689 scm_syserror (s_recvfrom
);
691 address
= scm_addr_vector ((struct sockaddr
*) scm_addr_buffer
, s_recvfrom
);
693 address
= SCM_BOOL_F
;
695 return scm_cons (SCM_MAKINUM (rv
), address
);
698 SCM_PROC (s_sendto
, "sendto", 4, 0, 1, scm_sendto
);
701 scm_sendto (sock
, message
, fam
, address
, args_and_flags
)
711 struct sockaddr
*soka
;
714 SCM_ASSERT (SCM_NIMP (sock
) && SCM_FPORTP (sock
), sock
, SCM_ARG1
, s_sendto
);
715 SCM_ASSERT (SCM_NIMP (message
) && SCM_ROSTRINGP (message
), message
,
717 SCM_ASSERT (SCM_INUMP (fam
), fam
, SCM_ARG3
, s_sendto
);
718 fd
= fileno ((FILE *)SCM_STREAM (sock
));
720 soka
= scm_fill_sockaddr (SCM_INUM (fam
), address
, &args_and_flags
, 4,
722 if (SCM_NULLP (args_and_flags
))
726 SCM_ASSERT (SCM_NIMP (args_and_flags
) && SCM_CONSP (args_and_flags
),
727 args_and_flags
, SCM_ARG5
, s_sendto
);
728 flg
= scm_num2ulong (SCM_CAR (args_and_flags
), (char *) SCM_ARG5
, s_sendto
);
730 SCM_SYSCALL (rv
= sendto (fd
, SCM_ROCHARS (message
), SCM_ROLENGTH (message
),
733 scm_syserror (s_sendto
);
734 scm_must_free ((char *) soka
);
736 return SCM_MAKINUM (rv
);
744 /* protocol families. */
746 scm_sysintern ("AF_UNSPEC", SCM_MAKINUM (AF_UNSPEC
));
749 scm_sysintern ("AF_UNIX", SCM_MAKINUM (AF_UNIX
));
752 scm_sysintern ("AF_INET", SCM_MAKINUM (AF_INET
));
756 scm_sysintern ("PF_UNSPEC", SCM_MAKINUM (PF_UNSPEC
));
759 scm_sysintern ("PF_UNIX", SCM_MAKINUM (PF_UNIX
));
762 scm_sysintern ("PF_INET", SCM_MAKINUM (PF_INET
));
767 scm_sysintern ("SOCK_STREAM", SCM_MAKINUM (SOCK_STREAM
));
770 scm_sysintern ("SOCK_DGRAM", SCM_MAKINUM (SOCK_DGRAM
));
773 scm_sysintern ("SOCK_RAW", SCM_MAKINUM (SOCK_RAW
));
776 /* setsockopt level. */
778 scm_sysintern ("SOL_SOCKET", SCM_MAKINUM (SOL_SOCKET
));
781 scm_sysintern ("SOL_IP", SCM_MAKINUM (SOL_IP
));
784 scm_sysintern ("SOL_TCP", SCM_MAKINUM (SOL_TCP
));
787 scm_sysintern ("SOL_UDP", SCM_MAKINUM (SOL_UDP
));
790 /* setsockopt names. */
792 scm_sysintern ("SO_DEBUG", SCM_MAKINUM (SO_DEBUG
));
795 scm_sysintern ("SO_REUSEADDR", SCM_MAKINUM (SO_REUSEADDR
));
798 scm_sysintern ("SO_STYLE", SCM_MAKINUM (SO_STYLE
));
801 scm_sysintern ("SO_TYPE", SCM_MAKINUM (SO_TYPE
));
804 scm_sysintern ("SO_ERROR", SCM_MAKINUM (SO_ERROR
));
807 scm_sysintern ("SO_DONTROUTE", SCM_MAKINUM (SO_DONTROUTE
));
810 scm_sysintern ("SO_BROADCAST", SCM_MAKINUM (SO_BROADCAST
));
813 scm_sysintern ("SO_SNDBUF", SCM_MAKINUM (SO_SNDBUF
));
816 scm_sysintern ("SO_RCVBUF", SCM_MAKINUM (SO_RCVBUF
));
819 scm_sysintern ("SO_KEEPALIVE", SCM_MAKINUM (SO_KEEPALIVE
));
822 scm_sysintern ("SO_OOBINLINE", SCM_MAKINUM (SO_OOBINLINE
));
825 scm_sysintern ("SO_NO_CHECK", SCM_MAKINUM (SO_NO_CHECK
));
828 scm_sysintern ("SO_PRIORITY", SCM_MAKINUM (SO_PRIORITY
));
831 scm_sysintern ("SO_LINGER", SCM_MAKINUM (SO_LINGER
));
834 /* recv/send options. */
836 scm_sysintern ("MSG_OOB", SCM_MAKINUM (MSG_OOB
));
839 scm_sysintern ("MSG_PEEK", SCM_MAKINUM (MSG_PEEK
));
842 scm_sysintern ("MSG_DONTROUTE", SCM_MAKINUM (MSG_DONTROUTE
));
845 scm_add_feature ("socket");
846 scm_init_addr_buffer ();