Here is a piece of my code:
Code: Select all
PSP_MODULE_INFO( "wifiuser", 0, 1, 0 );
PSP_MAIN_THREAD_ATTR( PSP_THREAD_ATTR_USER );
......
int wifiInit( const char * ip_addr, int port )
{
struct sockaddr_in addr;
int flag = 1, cmd, res;
log( "ip %s port %d\n", ip_addr, port );
if ( connectApctl( 1 ) < 0 )
{
return -1;
}
sock_server = sceNetInetSocket( PF_INET, SOCK_STREAM, 0 );
if ( sock_server < 0 )
{
log( "Error create sock connection\n" );
return -1;
}
log( "create sock %08x\n", sock_server );
int ret = sceNetInetSetsockopt( sock_server, SOL_TCP, TCP_NODELAY, &flag, sizeof( flag ) );
log ( "ret %08x\n", ret );
addr.sin_family = AF_INET;
addr.sin_port = htons( 7513 );
addr.sin_addr.s_addr = sceNetInetInetAddr( ip_addr );
log( "ip address %08x\n", ( unsigned int )addr.sin_addr.s_addr );
ret = sceNetInetConnect( sock_server, ( struct sockaddr * )&addr, sizeof( addr ) );
log ( "ret %08x\n", ret );
if ( ret < 0 )
{
log( "Error connect to sock %08x\n", sock_server );
return -1;
}
}
......
int module_start( SceSize args, void *argp )
{
thid = sceKernelCreateThread( "wifhost_thread", main_thread, 0x20, 0x10000, PSP_THREAD_ATTR_USER, NULL );
if( thid >= 0 )
sceKernelStartThread( thid, 0, 0 );
return 0;
}
int module_stop( SceSize args, void *argp )
{
return 0;
}
Code: Select all
connection state 0
connection state 2
connection state 3
connection state 4
ip 192.168.1.27 port 7513
create sock 0000000b
ret 00000000
ip address 1b01a8c0
I had a lots modification try on the sockaddr_in structure and the thread stack size, but no result, is it just looping in sceNetInetConnect? or I passed something wrong? it almost drove me mad..