static int lua_channel_connect(lua_State *L) { struct peer_extra *pse = NULL; struct protocol_extra *pe = NULL; struct channel_extra *ce; assert(L == luastate); if(lua_gettop(L) != 3 || (pse = lua2peer(L, 1)) == NULL || (pe = lua2protocol(L, 2)) == NULL || !lua_isfunction(L, 3)) { luaL_error(L, "wrong number or type of arguments"); } trace(LOG_LUA, "lua_channel_connect %p", pse->ps); if(pse->ps == NULL) luaL_error(L, "stale peer"); ce = (struct channel_extra *)lua_newuserdata(L, sizeof *ce); memset(ce, 0, sizeof *ce); lua_pushvalue(L, -1); /* Prevent GC while connection is active */ ce->self_refp = luaref_new(L, ce); ce->L = L; ce->pe = lua_protocol_ref(pe, 2); luaL_getmetatable(L, "tcf_channel"); lua_setmetatable(L, -2); lua_pushvalue(L, 3); ce->connect_cbrefp = luaref_new(L, ce); channel_connect(pse->ps, lua_channel_connect_cb, ce); return 0; }
/** * spice_channel_open_fd: * @channel: * @fd: a file descriptor (socket) * * Connect the channel using @fd socket. * * Returns: %TRUE on success. **/ gboolean spice_channel_open_fd(SpiceChannel *channel, int fd) { spice_channel *c = SPICE_CHANNEL_GET_PRIVATE(channel); g_return_val_if_fail(c != NULL, FALSE); g_return_val_if_fail(fd >= 0, FALSE); c->fd = fd; return channel_connect(channel); }
static void connect_dest(void * x) { Channel * c1 = (Channel *)x; PeerServer * ps; ConnectInfo * info; ps = channel_peer_from_url(dest_url); if (ps == NULL) { trace(LOG_ALWAYS, "cannot parse peer url: %s", dest_url); channel_close(c1); return; } channel_lock(c1); c1->state = ChannelStateRedirectReceived; info = (ConnectInfo *)loc_alloc_zero(sizeof(ConnectInfo)); info->ps = ps; info->c1 = c1; channel_connect(ps, connect_done, info); }
/** * spice_channel_connect: * @channel: * * Connect the channel, using #SpiceSession connection informations * * Returns: %TRUE on success. **/ gboolean spice_channel_connect(SpiceChannel *channel) { return channel_connect(channel); }