 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
AlphaDingDong
Joined: 21 Mar 2008 Posts: 29 Location: The interwebs
|
Posted: Thu Nov 12, 2009 6:59 am Post subject: Problems with sceNetResolverStartNtoA() |
|
|
I recently upgraded to 5.00m33-6 and also updated my toolchain to revision 2487.
I've been working to try and get net functionality into Lua Player Euphoria, but I'm having a hell of a time with the resolver.
I'm fairly certain this is the same code I used before, but suddenly it doesn't want to work. Specifically sceNetResolverStartNtoA() is simply hanging. It blocks the thread and never returns. Other threads continue running. I've let the thing sit for several minutes. I wrote up a quick test app to demonstrate. Is anyone aware of a change to the SDK/FW that's preventing this from working? Otherwise can anyone spot something I'm screwing up here?
| Code: | //{Inclusions
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <malloc.h>
#include <pspsdk.h>
#include <unistd.h>
#include <pspnet.h>
#include <psputility.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>
#include <pspnet_resolver.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <pspwlan.h>
#include <errno.h>
#include <string.h>
#include <pspgu.h>
#include <stdarg.h>
//}
PSP_MODULE_INFO("resolver", 0, 1, 1);
u32* list;
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp) {
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
void setupCallbacks() {
int thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {sceKernelStartThread(thid, 0, 0);}
}
void debug(char* msg, ...) {
va_list args;
va_start(args, msg);
pspDebugScreenInit();
pspDebugScreenPrintf(msg, args);
va_end(args);
sceKernelSleepThread();
}
void startGfx() {
list = (unsigned*)memalign(16, 262144);
sceGuInit();
sceGuStart(GU_DIRECT, list);
sceGuDrawBuffer(GU_PSM_8888, (void*)0, 512);
sceGuDispBuffer(480, 272, (void*)0x88000, 512);
sceGuDepthBuffer((void*)0x110000, 512);
sceGuOffset(1808, 1912);
sceGuViewport(2048, 2048, 480, 272);
sceGuDepthRange(0xFFFF, 0);
sceGuDepthFunc(GU_GEQUAL);
sceGuEnable(GU_DEPTH_TEST);
sceGuScissor(0, 0, 480, 272);
sceGuEnable(GU_SCISSOR_TEST);
sceGuAlphaFunc(GU_GREATER, 0, 0xFF);
sceGuEnable(GU_ALPHA_TEST);
sceGuTexMode(GU_PSM_8888, 0, 0, 0);
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuEnable(GU_TEXTURE_2D);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuEnable(GU_BLEND);
sceGuClearColor(0xFF000000);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
sceGuFinish();
sceGuSync(0, 0);
sceGuDisplay(GU_TRUE);
}
void startNet() {
int ret = sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
if(ret) {debug("Error loading common module, %x", ret);}
ret = sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
if(ret) {debug("Error loading inet module, %x", ret);}
ret = sceNetInit(128*1024, 42, 4*1024, 42, 4*1024);
if(ret) {debug("Error in sceNetInit, %x", ret);}
ret = sceNetInetInit();
//if(ret) {debug("Error in sceNetInetInit (?) %x", ret);} //no docs on return values, but I doubt this is the problem
ret = sceNetApctlInit(0x8000, 48);
if(ret < 0) {debug("Error in sceNetApctlInit, %x", ret);}
ret = sceNetResolverInit();
if(ret) {debug("Error in sceNetResolverInit, %x", ret);}
}
void connectAP() {
pspUtilityNetconfData data;
memset(&data, 0, sizeof(data));
data.base.size = sizeof(data);
data.base.language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
data.base.buttonSwap = PSP_UTILITY_ACCEPT_CROSS;
data.base.graphicsThread = 18;
data.base.accessThread = 20;
data.base.fontThread = 19;
data.base.soundThread = 17;
data.action = PSP_NETCONF_ACTION_CONNECTAP;
struct pspUtilityNetconfAdhoc adhocparam;
memset(&adhocparam, 0, sizeof(adhocparam));
data.adhocparam = &adhocparam;
sceUtilityNetconfInitStart(&data);
int running = 1;
while(running) {
sceGuStart(GU_DIRECT, list);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGuFinish();
sceGuSync(0,0);
switch(sceUtilityNetconfGetStatus()) {
case PSP_UTILITY_DIALOG_VISIBLE: sceUtilityNetconfUpdate(1); break;
case PSP_UTILITY_DIALOG_QUIT: sceUtilityNetconfShutdownStart(); break;
case PSP_UTILITY_DIALOG_NONE: running = 0; break;
}
sceGuSwapBuffers();
}
}
uint32_t resolve() {
int rid = 0;
char buf[1024];
struct in_addr addr;
memset(&addr, 0, sizeof(addr));
int ret = sceNetResolverCreate(&rid, buf, 1024);
if(ret) {debug("Error in sceNetResolverCreate: %x", ret);}
ret = sceNetResolverStartNtoA(rid, "google.com", &addr, 3, 3); //this function never returns
if(ret) {debug("Error in sceNetResolverStartNtoA: %x", ret);}
ret = sceNetResolverDelete(rid);
if(ret) {debug("Error in sceNetResolverDelete: %x", ret);}
return addr.s_addr;
}
int main() {
setupCallbacks();
startGfx();
startNet();
connectAP();
uint32_t address = resolve();
char str[INET_ADDRSTRLEN];
inet_ntop(AF_INET, (void*)&address, str, INET_ADDRSTRLEN);
debug("Success.\nAddress is: %s", str);
return 0;
} |
| Code: | TARGET = resolver
TARGET_FOLDER = K:/PSP/GAME/$(TARGET)
OBJS = main.o
CFLAGS = -O3 -G0 -Wall -Werror
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Resolver Test
PSP_LARGE_MEMORY = 1
PSP_FW_VERSION = 371
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
eboot:
@if [ -f EBOOT.PBP ]; then echo "Found EBOOT.PBP."; else $(MAKE) --no-print-directory all; fi
@echo "Moving EBOOT to PSP..."
@mv EBOOT.PBP $(TARGET_FOLDER)
update:
@$(MAKE) --no-print-directory eboot
@echo "Done."
install:
@echo "[Installing to PSP]"
@if [ -d $(TARGET_FOLDER) ]; then echo "Found project folder."; else echo "Creating project folder..."; mkdir $(TARGET_FOLDER); fi
@$(MAKE) --no-print-directory eboot
@echo "[Installation complete]" |
|
|
| Back to top |
|
 |
sakya
Joined: 28 Apr 2006 Posts: 190
|
Posted: Thu Nov 12, 2009 7:32 pm Post subject: |
|
|
Hi! :)
I had the same problem, I didn't solve it, but using the standard
| Code: | struct hostent *host;
host = gethostbyname(address); |
seems to work.
Ciaooo
Sakya |
|
| Back to top |
|
 |
AlphaDingDong
Joined: 21 Mar 2008 Posts: 29 Location: The interwebs
|
Posted: Fri Nov 13, 2009 4:48 am Post subject: |
|
|
Thanks, sakya.
I'll give it a shot. :) |
|
| Back to top |
|
 |
AlphaDingDong
Joined: 21 Mar 2008 Posts: 29 Location: The interwebs
|
Posted: Fri Nov 13, 2009 11:24 am Post subject: |
|
|
Hmm... I'm getting the same behavior. ???
It tried this:
| Code: | uint32_t resolve() {
struct hostent* host = gethostbyname("google.com");
if(host == NULL) {debug("Failed to resolve host address.");}
struct in_addr* addr = (struct in_addr*)host->h_addr;
return addr->s_addr;
} |
But it hangs when it reaches gethostbyname(). This is completly bizzare.
Am I doing that lookup correctly? Still, I'd expect it to give an error rather than just sitting there like this. |
|
| Back to top |
|
 |
|
|
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
|