Lines Matching refs:client

52     Client  client = calloc( sizeof(*client), 1 );
54 client->channel = channel;
55 return client;
59 client_free( Client client )
61 sys_channel_close( client->channel );
62 client->channel = NULL;
63 free( client );
67 client_append( Client client, const char* str, int len );
70 client_handle_line( Client client, const char* cmd )
93 printf( "%p: << %s\n", client, temp );
96 printf( "client %p quitting\n", client );
97 client_free( client );
100 client_append( client, "type 'quit' to quit\n", -1 );
106 Client client = _client;
111 ret = sys_channel_read( client->channel, client->in_buff + client->in_pos, 1 );
113 fprintf(stderr, "client %p could not read byte, result = %d, error: %s\n",
114 client, ret, strerror(errno) );
117 if (client->in_buff[client->in_pos] == '\r' ||
118 client->in_buff[client->in_pos] == '\n' ) {
119 const char* cmd = client->in_buff;
120 client->in_buff[client->in_pos] = 0;
126 client_handle_line( client, cmd );
127 client->in_pos = 0;
129 client->in_pos += 1;
135 ret = sys_channel_write( client->channel, client->out_buff + client->out_pos, 1 );
137 fprintf(stderr, "client %p could not write byte, result = %d, error: %s\n",
138 client, ret, strerror(errno) );
141 client->out_pos += 1;
142 if (client->out_pos == client->out_size) {
143 client->out_size = 0;
144 client->out_pos = 0;
146 sys_channel_on( client->channel, SYS_EVENT_READ, client_handler, client );
152 printf( "client %p exiting\n", client );
153 client_free( client );
157 client_append( Client client, const char* str, int len )
164 avail = sizeof(client->out_buff) - client->out_size;
168 memcpy( client->out_buff + client->out_size, str, len );
169 if (client->out_size == 0) {
170 sys_channel_on( client->channel, SYS_EVENT_READ | SYS_EVENT_WRITE, client_handler, client );
172 client->out_size += len;
181 Client client;
185 printf( "got one. creating client\n" );
186 client = client_alloc( handler );
189 sys_channel_on( handler, SYS_EVENT_READ, client_handler, client );
190 client_append( client, "Welcome !\n", -1 );