set sockaddr_un.sun_len on the systems that have sockaddr.sa_len.
If your system has sa_len but is not BSD-derived, define HAVE_SA_LEN=1
on mrbgem.rake or build_config.rb.
MODIFY
mrbgems/mruby-socket/mrbgem.rake
mrbgems/mruby-socket/mrbgem.rake
@@ -4,6 +4,7 @@ MRuby::Gem::Specification.new('mruby-socket') do |spec|
spec.summary = 'standard socket class'
spec.cc.include_paths << "#{build.root}/src"
+ #spec.cc.defines << "HAVE_SA_LEN=0"
# If Windows, use winsock
if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then

MODIFY
mrbgems/mruby-socket/src/socket.c
mrbgems/mruby-socket/src/socket.c
#else
#include <sys/types.h>
#include <sys/socket.h>
+ #include <sys/param.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include "mruby/ext/io.h"
+#if !defined(HAVE_SA_LEN)
+#if (defined(BSD) && (BSD >= 199006))
+#define HAVE_SA_LEN 1
+#else
+#define HAVE_SA_LEN 0
+#endif
+#endif
+
#define E_SOCKET_ERROR (mrb_class_get(mrb, "SocketError"))
#if !defined(mrb_cptr)
@@ -695,6 +704,9 @@ mrb_socket_sockaddr_un(mrb_state *mrb, mrb_value klass)
}
s = mrb_str_buf_new(mrb, sizeof(struct sockaddr_un));
sunp = (struct sockaddr_un *)RSTRING_PTR(s);
+#if HAVE_SA_LEN
+ sunp->sun_len = sizeof(struct sockaddr_un);
+#endif
sunp->sun_family = AF_UNIX;
memcpy(sunp->sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
sunp->sun_path[RSTRING_LEN(path)] = '\0';

set sockaddr_un.sun_len on the systems that have sockaddr.sa_len.

If your system has sa_len but is not BSD-derived, define HAVE_SA_LEN=1
on mrbgem.rake or build_config.rb.