- const char *address = luaL_checkstring(L, 3);
- struct sockaddr_storage addrstor;
- addr = (struct sockaddr*)&addrstor;
-
- nixio_addr naddr;
- memset(&naddr, 0, sizeof(naddr));
- strncpy(naddr.host, address, sizeof(naddr.host) - 1);
- naddr.port = (uint16_t)luaL_checkinteger(L, 4);
- naddr.family = sock->domain;
-
- if (nixio__addr_write(&naddr, addr)) {
- return nixio__perror_s(L);
+ if (sock->domain == AF_INET || sock->domain == AF_INET6) {
+ const char *address = luaL_checkstring(L, 3);
+ addr = (struct sockaddr*)&addr_in;
+ alen = sizeof(addr_in);
+
+ nixio_addr naddr;
+ memset(&naddr, 0, sizeof(naddr));
+ strncpy(naddr.host, address, sizeof(naddr.host) - 1);
+ naddr.port = (uint16_t)luaL_checkinteger(L, 4);
+ naddr.family = sock->domain;
+
+ if (nixio__addr_write(&naddr, addr)) {
+ return nixio__perror_s(L);
+ }