summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/socket.c b/socket.c
index b562fd5..6296b38 100644
--- a/socket.c
+++ b/socket.c
@@ -46,6 +46,12 @@
*/
#include "scm.h"
+
+#ifdef macintosh
+#define SOCKETDEFS
+#include "macsocket.h"
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -242,8 +248,9 @@ SCM l_servinfo(args)
proto = CAR(proto);
ASSERT(NIMP(proto) && STRINGP(proto), args, ARG2, s_servinfo);
DEFER_INTS;
- if (NIMP(name) && STRINGP(name))
+ if (NIMP(name) && STRINGP(name)) {
SYSCALL(entry = getservbyname(CHARS(name), CHARS(proto)););
+ }
else {
ASSERT(INUMP(proto), proto, ARG1, s_servinfo);
SYSCALL(entry = getservbyport(INUM(proto), CHARS(proto)););
@@ -310,7 +317,11 @@ SCM l_socket(fam, proto)
i_setbuf0(port);
ALLOW_INTS;
if (AF_INET==tp) {
+#ifdef macintosh
+ sd = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&j, sizeof(j));
+#else
sd = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &j, sizeof(j));
+#endif
ASSERT(!sd, port, "could not set socket option", s_socket);
}
return port;
@@ -469,11 +480,15 @@ SCM l_accept(sockpt)
NEWCELL(newpt);
ASSERT(NIMP(sockpt) && OPINPORTP(sockpt), sockpt, ARG1, s_accept);
sadlen=sizeof(sad);
- DEFER_INTS;
SYSCALL(newsd = accept(fileno(STREAM(sockpt)), &sad, &sadlen););
- if (-1==newsd)
+ if (-1==newsd) {
+#ifndef macintosh
if (EWOULDBLOCK != errno) return BOOL_F;
- else wta(sockpt, "couldn't", s_accept);
+ else
+#endif
+ wta(sockpt, "couldn't", s_accept);
+ }
+ DEFER_INTS;
SYSCALL(newfd = fdopen(newsd, "r+"););
if (!newfd) {
close(newsd);
@@ -511,7 +526,7 @@ int sknm_print(exp, port, writing)
sizet sknm_free(p)
CELLPTR p;
{
- must_free(CHARS((SCM)p));
+ must_free(CHARS((SCM)p), sizeof(struct sockaddr));
return sizeof(struct sockaddr);
}
long tc16_sknm;
@@ -558,12 +573,11 @@ SCM maksknm(sad)
{
SCM sknm;
struct sockaddr *msknm;
- NEWCELL(sknm);
DEFER_INTS;
- msknm = (struct sockaddr *)must_malloc(0L+sizeof(struct sockaddr), "sknm");
+ sknm = must_malloc_cell(0L+sizeof(struct sockaddr), "sknm");
+ msknm = (struct sockaddr *)CDR(sknm);
*msknm = *sad;
CAR(sknm) = tc16_sknm;
- SETCDR(sknm, msknm);
ALLOW_INTS;
return sknm;
}