Lines Matching refs:channel
181 SysChannel channel = _s_free_channels;
182 if (channel != NULL) {
183 _s_free_channels = channel->next;
184 channel->next = NULL;
185 channel->fd = -1;
186 channel->callback = NULL;
187 channel->opaque = NULL;
189 return channel;
193 sys_channel_free( SysChannel channel )
195 if (channel->fd >= 0) {
196 socket_close( channel->fd );
197 channel->fd = -1;
199 channel->next = _s_free_channels;
200 _s_free_channels = channel;
207 SysChannel channel = _channel;
208 D( "%s: read event for channel %p:%d\n", __FUNCTION__,
209 channel, channel->fd );
210 channel->callback( channel->opaque, SYS_EVENT_READ );
216 SysChannel channel = _channel;
217 D( "%s: write event for channel %p:%d\n", __FUNCTION__, channel, channel->fd );
218 channel->callback( channel->opaque, SYS_EVENT_WRITE );
222 sys_channel_on( SysChannel channel,
236 channel->callback = event_callback;
237 channel->opaque = event_opaque;
238 qemu_set_fd_handler( channel->fd, read_handler, write_handler, channel );
242 sys_channel_read( SysChannel channel, void* buffer, int size )
248 int ret = socket_recv(channel->fd, buf, len);
269 sys_channel_write( SysChannel channel, const void* buffer, int size )
275 int ret = socket_send(channel->fd, buf, len);
294 void sys_channel_close( SysChannel channel )
296 qemu_set_fd_handler( channel->fd, NULL, NULL, NULL );
297 sys_channel_free( channel );
319 SysChannel channel = sys_channel_alloc();
321 channel->fd = socket_anyaddr_server( port, SOCKET_STREAM );
322 if (channel->fd < 0) {
325 sys_channel_free( channel );
329 D( "%s: server channel %p:%d now listening on port %d\n",
330 __FUNCTION__, channel, channel->fd, port );
332 return channel;
339 SysChannel channel = sys_channel_alloc();
341 D( "%s: creating handler from server channel %p:%d\n", __FUNCTION__,
344 channel->fd = socket_accept_any( server_channel->fd );
345 if (channel->fd < 0) {
347 sys_channel_free( channel );
352 socket_set_nodelay( channel->fd );
355 server_channel, server_channel->fd, channel, channel->fd );
357 return channel;
364 SysChannel channel = sys_channel_alloc();
366 channel->fd = socket_network_client( hostname, port, SOCKET_STREAM );
367 if (channel->fd < 0) {
368 sys_channel_free(channel);
373 socket_set_nonblock( channel->fd );
374 socket_set_nodelay( channel->fd );
376 return channel;