forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

asynchronous network io

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
jockyw2001



Joined: 29 Sep 2005
Posts: 339

PostPosted: Fri Apr 07, 2006 12:39 am    Post subject: asynchronous network io Reply with quote

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:

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;
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group