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 

ps2ip connect to PC problem

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



Joined: 07 Jul 2005
Posts: 7

PostPosted: Sat Sep 03, 2005 8:14 pm    Post subject: ps2ip connect to PC problem Reply with quote

Hi guys,

I'm having trouble trying to write code to get my PS2 to connect to a PC using ps2ip.
I am using the latest ps2sdk.
I reset the iop and load the modules as follows:

Code:
SifExitRpc();
SifIopReset("rom0:UDNL rom0:EELOADCNF", 0);
while(!SifIopSync());

SifInitRpc(0);

if(SifLoadFileInit() != 0)
    return; // bind failed.

log(LOG_SYSTEM, LOG_INFO, "Loading LIBSD module");
if (SifLoadModule("rom0:LIBSD", 0, NULL) < 0)
{
    log(LOG_SYSTEM, LOG_ERROR, "Failed to load LIBSD module");
}

log(LOG_SYSTEM, LOG_INFO, "Loading AUDSRV module");

if(SifExecModuleBuffer(audsrv_irx, size_audsrv_irx, 0, NULL, &i) < 0)
{
    log(LOG_SYSTEM, LOG_ERROR, "Failed to load AUDSRV module");
}

log(LOG_SYSTEM, LOG_INFO, "Loading PS2IP module");
if(SifExecModuleBuffer(ps2ip_irx, size_ps2ip_irx, 0, NULL, &i) < 0)
{
    log(LOG_SYSTEM, LOG_ERROR, "Failed to load PS2IP module");
}

log(LOG_SYSTEM, LOG_INFO, "Loading PS2IPS module");
if(SifExecModuleBuffer(ps2ips_irx, size_ps2ips_irx, 0, NULL, &i) < 0)
{
    log(LOG_SYSTEM, LOG_ERROR, "Failed to load PS2IPs module");
}

log(LOG_SYSTEM, LOG_DEBUG, "Initialising ps2ip");

ps2ip_init();


Everything seems to be fine here, all modules load OK. Next I try to connect to the PC using the following code:


Code:
struct sockaddr_in server;
s32 socket = -1;
s32 retcount = 0;
ip_addr addr;

socket = socket(AF_INET, SOCK_STREAM, 0);
if(socket < 0)
{
    log(LOG_DATASOURCE, LOG_ERROR, "HttpDataSource::open failed to create socket");
    return false;
}

memset(&server, 0, sizeof(server));

server.sin_family = AF_INET;
IP4_ADDR(&addr, 192, 168, 1, 2);
server.sin_addr.s_addr = addr.addr;

server.sin_port = htons(80);

if(connect(m_socket, (struct sockaddr*)&server, sizeof(server)) < 0)
{
    log(LOG_DATASOURCE, LOG_ERROR, "HttpDataSource::open failed to connect");
    return false;
}


According to the debug, the call to socket succeeds, whereas the call to connect fails. I can connect to
the port using telnet on ps2linux, so it shouldn't be a problem with the network etc.

Can anyone see anything obviously wrong with this code?

Does anyone know of any projects that use ps2ip to connect to servers on remote machines? Everything
I look at sets up a server on the ps2 and connects to it from the PC.

Also, does anyone know if gethostbyname works? This seems to be defined in the irx, but not in the
ps2ip ee code.

Thanks for any tips you can give.

// TJ
Back to top
View user's profile Send private message
apache37



Joined: 04 Jun 2004
Posts: 76

PostPosted: Sun Sep 04, 2005 10:23 am    Post subject: Reply with quote

Maybe it's me but where's your SMAP setup?
Back to top
View user's profile Send private message
TJ



Joined: 07 Jul 2005
Posts: 7

PostPosted: Sun Sep 04, 2005 9:58 pm    Post subject: Reply with quote

Thanks for the reply.

I'm not 100% sure what SMAP setup is, but I think you mean that I need to set my IP address etc. Now I have added a call to ps2ip_setconfig as follows, which seems to succeed, but still no success on connecting.

Code:
log(LOG_SYSTEM, LOG_DEBUG, "Initialising ps2ip");

t_ip_info ipinfo;
ip_addr addr;


ps2ip_init();

memset(&ipinfo, 0, sizeof(ipinfo));
strcpy(ipinfo.netif_name, "et");

IP4_ADDR(&addr, 192, 168, 1, 20);
ipinfo.ipaddr.s_addr = addr.addr;
IP4_ADDR(&addr, 255, 255, 255, 0);
ipinfo.netmask.s_addr = addr.addr;

IP4_ADDR(&addr, 192, 168, 1, 1);
ipinfo.gw.s_addr = addr.addr;
ipinfo.dns_server.s_addr = addr.addr;

if(ps2ip_setconfig(&ipinfo) == 0)
{
    log(LOG_SYSTEM, LOG_ERROR, "Failed to set ps2ip config");
}


Anything else I'm missing??

// TJ
Back to top
View user's profile Send private message
apache37



Joined: 04 Jun 2004
Posts: 76

PostPosted: Mon Sep 05, 2005 7:42 am    Post subject: Reply with quote

Yes :p

Ok.. here's the order I use:

Code:
   /* oppen the expansion bay */
   SifLoadModule("host:/irx/PS2DEV9.IRX", 0, NULL);

   /* load the stack */
   SifLoadModule("host:/irx/PS2IP.IRX", 0, NULL);
   SifLoadModule("host:/irx/PS2IPS.IRX", 0, NULL);

   /* load up smap with static settings */
   strcpy(&args[a], IP); a += strlen(IP) + 1;
   strcpy(&args[a], NM); a += strlen(NM) + 1;
   strcpy(&args[a], GW); a += strlen(GW) + 1;
   SifLoadModule("host:/irx/SMAPX.IRX", a, args);


After this you can do ps2ip_init(). You need DEV9 and SMAP to initialize the hardware side. Take a look at the ps2link source for more info.
Hope this helps.

BTW if anyone is reading what's the story with dns.irx?? It has gethostbyname() but no ee side export for this. Is it incomplete or can I make it work?
Back to top
View user's profile Send private message
TJ



Joined: 07 Jul 2005
Posts: 7

PostPosted: Mon Sep 05, 2005 11:45 pm    Post subject: Reply with quote

Thanks for the help.

I was a bit thrown by the fact that the SMAP irx isnt in ps2sdk in svn, but I found it under ps2eth and now I can connect :)

// TJ
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 -> PS2 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