Last active
August 2, 2016 19:28
-
-
Save xerpi/e426284df19c217a8128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdarg.h> | |
#include <psp2/net/net.h> | |
#include <psp2/net/netctl.h> | |
static int _dbgsock = 0; | |
static void *net_memory = NULL; | |
void init_netdbg() | |
{ | |
#define NET_INIT_SIZE 1*1024*1024 | |
SceNetSockaddrIn server; | |
if (sceNetShowNetstat() == SCE_NET_ERROR_ENOTINIT) { | |
net_memory = malloc(NET_INIT_SIZE); | |
SceNetInitParam initparam; | |
initparam.memory = net_memory; | |
initparam.size = NET_INIT_SIZE; | |
initparam.flags = 0; | |
sceNetInit(&initparam); | |
sceKernelDelayThread(100*1000); | |
} | |
server.sin_len = sizeof(server); | |
server.sin_family = SCE_NET_AF_INET; | |
sceNetInetPton(SCE_NET_AF_INET, "192.168.1.40", &server.sin_addr); | |
server.sin_port = sceNetHtons(9023); | |
memset(server.sin_zero, 0, sizeof(server.sin_zero)); | |
_dbgsock = sceNetSocket("vitanetdbg", SCE_NET_AF_INET, SCE_NET_SOCK_STREAM, 0); | |
sceNetConnect(_dbgsock, (SceNetSockaddr *)&server, sizeof(server)); | |
} | |
void fini_netdbg() | |
{ | |
if (_dbgsock) { | |
sceNetSocketClose(_dbgsock); | |
sceNetTerm(); | |
if (net_memory) { | |
free(net_memory); | |
net_memory = NULL; | |
} | |
_dbgsock = 0; | |
} | |
} | |
void debug(char *text, ...) | |
{ | |
va_list list; | |
char string[512]; | |
va_start(list, text); | |
vsprintf(string, text, list); | |
va_end(list); | |
sceNetSend(_dbgsock, string, strlen(string), 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment