예제 #1
0
kaddress_t* knet_channel_ref_get_local_address(kchannel_ref_t* channel_ref) {
    verify(channel_ref);
    if (channel_ref->ref_info->local_address) {
        return channel_ref->ref_info->local_address;
    }
    channel_ref->ref_info->local_address = knet_address_create();
    socket_getsockname(channel_ref, channel_ref->ref_info->local_address);
    return channel_ref->ref_info->local_address;
}
예제 #2
0
파일: lsocket.c 프로젝트: nan1888/lask
/*
** addr, port, err = socket.getsockname(fd)
*/
static int lsocket_getsockname(lua_State *L) 
{
	int fd = luaL_checkinteger(L, 1);
	char addr[INET6_ADDRSTRLEN];
	int port = 0;
	int err = socket_getsockname(fd, addr, &port);
	if (err == 0) {
		lua_pushstring(L, addr);
		lua_pushinteger(L, port);
	} else {
		lua_pushnil(L);
		lua_pushnil(L);
	}
	lua_pushinteger(L, err);
	return 3;
}
예제 #3
0
int
ksocket_getsockname(ksocket_t ks, struct sockaddr *addr, socklen_t *addrlen,
    struct cred *cr)
{
	struct sonode *so;

	/* All Solaris components should pass a cred for this operation. */
	ASSERT(cr != NULL);

	if (!KSOCKET_VALID(ks))
		return (ENOTSOCK);

	so = KSTOSO(ks);

	if (addrlen == NULL || (addr == NULL && *addrlen != 0))
		return (EFAULT);

	return (socket_getsockname(so, addr, addrlen, cr));
}