Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - blizter

Pages: [1]
1
Network / Listen always returns Done
« on: December 10, 2011, 06:17:18 pm »
Code: [Select]
double net_tcp_listen(unsigned short port)
{
    TcpListener* sock = new TcpListener();

    sock->Listen(port);

    if(sock->GetLocalPort() == 0){
        delete sock;
        return 0;
    }

    return insertSock(sock);
}


How could this, running in two different process (I open my .exe twice), never return 0.

I tried MessageBox'ing the variables and indeed, GetLocalPort never returns 0.

My program calls network functions from multiple threads. I looked up just in case and Winsock is thread-safe. So I'm really confused.

I added debug messages:

Code: [Select]
Socket::Status TcpListener::Listen(unsigned short port)
{
    // Create the internal socket if it doesn't exist
    Create();

    // Bind the socket to the specified port
    sockaddr_in address = priv::SocketImpl::CreateAddress(INADDR_ANY, port);
    if (bind(GetHandle(), reinterpret_cast<sockaddr*>(&address), sizeof(address)) == -1)
    {
        // Not likely to happen, but...
        Err() << "Failed to bind listener socket to port " << port << std::endl;
        MessageBox( 0, "listen error", 0, MB_ICONERROR );
        return Error;
    }

    // Listen to the bound port
    if (listen(GetHandle(), 0) == -1)
    {
        // Oops, socket is deaf
        Err() << "Failed to listen to port " << port << std::endl;
        MessageBox( 0, "listen error", 0, MB_ICONERROR );
        return Error;
    }
    MessageBox( 0, to_string(port).c_str(), 0, MB_ICONERROR );

    return Done;
}


Both process show the same message box with the same port number.

2
Network / Listen always returns Done
« on: December 09, 2011, 03:33:54 pm »
Hello,

I'm using a TcpListener to listen to a port, I check if it worked with GetLocalPort, it return the port I chose.

Then if I open my application twice, both are listening apparently, I get no error. SFML seems to think it worked.

Obviously all the packets are only sent to the first instance that was opened.

What do you think might be causing this ?

I'm using Windows sockets.

3
System / Odd behaviour of thread
« on: June 11, 2011, 11:34:41 pm »
I had this problem and Drektar solution fixed it.

The created thread was running but not threaded. Weird.

4
Network / sfml2 network crash
« on: February 22, 2011, 05:30:49 pm »
Hey thank you. I got it working using the tcpsocket send(char*) function rather than the send(&Packet) one.

Had to send size of packet by myself but now it can handle packets of invalid size and all.

Thanks, using raw data was what I had to do.

5
Network / sfml2 network crash
« on: February 21, 2011, 05:05:56 pm »
With a third party tool. For this I am using WPEpro. To intercept the packets and resend them/modify to test hacking attempts.

6
Network / sfml2 network crash
« on: February 21, 2011, 04:51:09 pm »
Well it seems if someone resend a packet to "hack" and he doesn't send the first piece of information, the tcpsocket will try to read the packet as if it was that first piece of information "the size". Then it tries to read the second piece of information that isn't there and crash.

This is what I think it does.

7
Network / sfml2 network crash
« on: February 21, 2011, 04:29:01 pm »
So I have been writing a game server/client with the network part of sfml2. It wrote some nice encryptions mechanisms along with checksum check and messages id checks. All for nothing because if someone resend a packet, without first sending the "length" packet. (I don't know why you are sending 2 packets each time I call send) The server crash. Any script kiddie can crash the server.

Anything I can modify to ignore resent packets, or just not crash ?

Pages: [1]
anything