asynchronous network io

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

asynchronous network io

Post by jockyw2001 »

Did anyone figure out how to perform async wifi io?

Can it perhaps be done by splitting optixx's curl based net_io read routine in a read_async and a read_wait part ? If yes, where shall the cut point be?

Code: Select all

int net_io_read( netfd *fd, void *read_buffer, int size )
{
    
    char url[512];
    int ret;
    if (!fd){
	printf("net_io_read: invalid fd\n");
	fprintf(stderr,"net_io_read: invalid fd\n");
	return -1;
    }
    snprintf(url,511,"http://%s/read?fd=%i&size=%i",net_io_uri,fd->fd,size);
    if (net_io_debug) 
	fprintf(stdout,"net_io_read: url=%s\n",url);
    curl_easy_setopt(fd->curl, CURLOPT_URL, url );
    curl_easy_setopt(fd->curl, CURLOPT_WRITEFUNCTION, callback_read);  
    (void) sceKernelWaitSema(__net_io_state.sema_read, 1, 0);
    __net_io_state.read_offset = 0;
    __net_io_state.read_buffer = read_buffer;
    fd->res = curl_easy_perform(fd->curl);
    ret = __net_io_state.read_offset;
    (void) sceKernelSignalSema(__net_io_state.sema_read,1);
     
    if (fd->res != CURLE_OK) {
	printf("net_io_read: %s\n", curl_easy_strerror(fd->res));
	fprintf(stderr,"net_io_read: %s\n", curl_easy_strerror(fd->res));
	return -1;
    }
    curl_easy_getinfo(fd->curl,CURLINFO_SPEED_DOWNLOAD,&fd->speed); 
     __net_io_state.read_speed = fd->speed;
    return ret; 
} 
Post Reply