Hacking Connecting to a server PC with homebrew?

malucart

Well-Known Member
OP
Newcomer
Joined
Jul 24, 2016
Messages
59
Trophies
0
XP
145
Country
Brazil
My program is made up of a Wii U side and a PC side, but I can't seem to connect (via network ofc).
I do it just like Cafiine - on the C# app, AcceptTcpClient() on a TcpListener, and on the Wii U app, connect() a socket (resumed; there's some initialization too).

It doesn't connect at all though. I put some output, and it says "Connect error! Socket OK!"
Now seriously wtf? If the socket is OK why doesn't it connect?

Can someone help me? I promise, you will like the result.
 
D

Deleted User

Guest
It might help if I could see the code on the Wii U side of things.
I was able to get sockets to connect earlier, but wasn't able to send 8-bit data through them (it always ended up being $$$ signs on the Wii U).

Where does it say "Connect error?" The Wii U or the PC?
 

malucart

Well-Known Member
OP
Newcomer
Joined
Jul 24, 2016
Messages
59
Trophies
0
XP
145
Country
Brazil
On the Wii U, the PC just stays there "Listening for connections on port 7333". As I said, I do it just like Cafiine.

I use this:
Code:
int server_connect(int *psock, const char* server_ip) {
    struct sockaddr_in addr;
    int sock, ret;

    // No ip means that we don't have any server running, so no logs
    if (server_ip == 0) {
        *psock = -1;
        return 0;
    }

    socket_lib_init();

    sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if(sock < 0)
        return sock;

    addr.sin_family = AF_INET;
    addr.sin_port = 7333;
    addr.sin_addr.s_addr = server_ip;

    ret = connect(sock, (void *)&addr, sizeof(addr));
    if(ret < 0)
    {
        socketclose(sock);
        return -1;
    }

    int enable = 1;
    setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&enable, sizeof(enable));

    *psock = sock;
    iLock = 0;
    return 0;
}

To check I do this:
Code:
int* sock = -1;
int res = server_connect(sock, "192.168.0.8");
OSFatal(strcat(res < 0? "Connect error!" : "Connected!", sock < 0? " Socket error!" : " Socket OK!"));
 
D

Deleted User

Guest
I won't be able to test this on my own console, and probably won't be able to until Friday, but I think what's happening (in terms of your error code) is that you're concatenating the results of two separate errors.

In your case, you're trying to check for the result of whether the socket connected successfully, and then conatenating it with the result of the actual socket connection, which results in the "Connect error! Socket OK."

Not sure what's actually going wrong with the actual sockets, everything looks correct to me. I'm probably missing something, but I don;t really have time to thoroughly study the code. Sorry.
 

nexusmtz

Well-Known Member
Member
Joined
Feb 17, 2016
Messages
1,386
Trophies
0
XP
1,405
Country
United States
My program is made up of a Wii U side and a PC side, but I can't seem to connect (via network ofc).
It doesn't connect at all though. I put some output, and it says "Connect error! Socket OK!"
Now seriously wtf? If the socket is OK why doesn't it connect?

...
Code:
...
    sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if(sock < 0)
        return sock;
...
    ret = connect(sock, (void *)&addr, sizeof(addr));
    if(ret < 0)
    {
        socketclose(sock);
        return -1;
    }
...

To check I do this:
Code:
int* sock = -1;
int res = server_connect(sock, "192.168.0.8");
OSFatal(strcat(res < 0? "Connect error!" : "Connected!", sock < 0? " Socket error!" : " Socket OK!"));
Keep in mind that you get the socket before you tell it what remote address and port you're trying to connect to. It makes sense that the socket can be valid on the WiiU, but the connection can fail. You might want to change the order of the messages so they don't appear contradictory. Also, if getting the socket fails, you don't get to the connect part (res is actually sock), so the message is misleading in that case too.

Anyway, check your PC firewall to ensure that your new app and port are allowed, and do a wireshark capture to see if any packets are getting from the WiiU to the PC so you know which side the problem is on.
 

You may also like...

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3N1 @ K3N1: https://nypost.com/2022/12/02/putin-fell-down-stairs-soiled-himself-amid-health-woes-report/ +1