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

Author Topic: Example network program doesn't work on school network  (Read 12518 times)

0 Members and 1 Guest are viewing this topic.

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Example network program doesn't work on school network
« on: October 19, 2013, 02:38:25 am »
I get an error msg - Failed to set socket option "TCP_NODELAY" ; all your TCP packets will be buffered

What's wrong?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Example network program doesn't work on school network
« Reply #1 on: October 19, 2013, 02:48:10 am »
You probably don't have permission to set the TCP_NODELAY option on your socket, which is done automatically by SFML. This can be either because this is how the administrator configured it, your socket number is lower than 1024 in which case you shouldn't be able to create the socket in the first place, or although highly improbable the operating system doesn't support TCP_NODELAY.

Show us some code and we can figure out what might have caused it. However bear in mind, the cause is not something SFML has any influence on, so it will be up to you to fix the problem.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Example network program doesn't work on school network
« Reply #2 on: October 19, 2013, 03:38:52 am »
You probably don't have permission to set the TCP_NODELAY option on your socket, which is done automatically by SFML. This can be either because this is how the administrator configured it, your socket number is lower than 1024 in which case you shouldn't be able to create the socket in the first place, or although highly improbable the operating system doesn't support TCP_NODELAY.

Show us some code and we can figure out what might have caused it. However bear in mind, the cause is not something SFML has any influence on, so it will be up to you to fix the problem.
The code is the exact program on the github page. It runs fine at my home, but not at my school :(
So I'm guessing my school administrator configured it this way... Is there a workaround? :(
« Last Edit: October 19, 2013, 03:51:58 am by iride »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Example network program doesn't work on school network
« Reply #3 on: October 19, 2013, 03:59:03 am »
The code is the exact program on the github page.
You really need to be more specific than this. What program? There are multiple, and each takes their own parameters. We aren't psychic...

It runs fine at my home, but not at my school :(
Did you even read what I posted? Unless you are bringing the same physical computer (laptop) to school and accessing the school network from your laptop running the same operating system, things will be different because the computers are configured differently. SFML doesn't automatically give you administrator privileges. I wouldn't be surprised if this was security related. Like I said, go to the administrator and ask them why you can't set TCP_NODELAY on sockets. This might not even be an SFML problem. If you are still convinced SFML can change this, at least provide information about the school computer. What operating system does it run? What version of that operating system? Can the other examples run fine? Can other network programs run fine? How did you run the program?

Like I said, we are not psychic. We need more information besides "it doesn't work on my school network". We don't even know what exactly this it even is.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Example network program doesn't work on school network
« Reply #4 on: October 19, 2013, 04:27:32 am »
The code is the exact program on the github page.
You really need to be more specific than this. What program? There are multiple, and each takes their own parameters. We aren't psychic...

It runs fine at my home, but not at my school :(
Did you even read what I posted? Unless you are bringing the same physical computer (laptop) to school and accessing the school network from your laptop running the same operating system, things will be different because the computers are configured differently. SFML doesn't automatically give you administrator privileges. I wouldn't be surprised if this was security related. Like I said, go to the administrator and ask them why you can't set TCP_NODELAY on sockets. This might not even be an SFML problem. If you are still convinced SFML can change this, at least provide information about the school computer. What operating system does it run? What version of that operating system? Can the other examples run fine? Can other network programs run fine? How did you run the program?

Like I said, we are not psychic. We need more information besides "it doesn't work on my school network". We don't even know what exactly this it even is.

I'm sorry if I didn't make this clear. I was referring to this example code on github page https://github.com/SFML/SFML/tree/master/examples/sockets

Ok, now i understand that this has got to do with school computers, not the school internet.

Since this doesn't seem to be a SFML problem like you said, is there any workaround other than telling my school administrator to reconfigure the school computers so that SFML has permission to set TCP_NODELAY (They won't do it)

« Last Edit: October 19, 2013, 04:32:02 am by iride »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Example network program doesn't work on school network
« Reply #5 on: October 19, 2013, 04:38:58 am »
What other output is produced when you run the program?
How did you run it? As a server/client or both?
Does the program function as expected even when the error gets shown on the console or does it not do anything?

You can also try adding
std::cout << WSAGetLastError() << std::endl;
to the end of the main() function right before it returns and show us the error number that gets printed.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Example network program doesn't work on school network
« Reply #6 on: October 21, 2013, 06:54:22 pm »


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Example network program doesn't work on school network
« Reply #7 on: October 21, 2013, 07:12:42 pm »
Since everything fails, and you get error 10038 (WSAENOTSOCK: "socket operation on nonsocket"), it seems like the sockets are not even created for some reason. I should definitely add a check to make the error clearer.

However I have no idea why you wouldn't be able to create any socket. But I'm sure binary1248 has some hints ;)
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Example network program doesn't work on school network
« Reply #8 on: October 21, 2013, 10:00:36 pm »
Paste the following code into a new project, build it, run it, and paste the output of the program here.
#pragma comment( lib, "Ws2_32.lib" )

#include <iostream>
#include <windows.h>

int main() {
        int error = 0;

        WSADATA data;
        error = WSAStartup( MAKEWORD( 2, 2 ), &data );

        if( error ) {
                std::cout << "WSAStartup() failed: " << error << "\n";
                return -1;
        }

        SOCKET s = socket( PF_INET, SOCK_STREAM, 0 );

        if( s == INVALID_SOCKET ) {
                std::cout << "socket() failed: " << WSAGetLastError() << "\n";
                return -1;
        }

        u_long block = 1;
        error = ioctlsocket( s, FIONBIO, &block );

        if( error == SOCKET_ERROR ) {
                std::cout << "ioctlsocket() failed: " << WSAGetLastError() << "\n";
                return -1;
        }

        int no_delay = 1;

        error = setsockopt( s, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>( &no_delay ), sizeof( no_delay ) );

        if( error == SOCKET_ERROR ) {
                std::cout << "setsockopt() failed: " << WSAGetLastError() << "\n";
                return -1;
        }

        error = closesocket( s );

        if( error == SOCKET_ERROR ) {
                std::cout << "closesocket() failed: " << WSAGetLastError() << "\n";
                return -1;
        }

        error = WSACleanup();

        if( error == SOCKET_ERROR ) {
                std::cout << "WSACleanup() failed: " << WSAGetLastError() << "\n";
                return -1;
        }

        std::cout << "Everything completed successfully.\n";

        return 0;
}
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Example network program doesn't work on school network
« Reply #9 on: October 22, 2013, 08:17:15 pm »
socket() failed: 10022

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Example network program doesn't work on school network
« Reply #10 on: October 22, 2013, 08:21:09 pm »
MSDN says
Quote
WSAEINVAL (10022): Invalid argument

I have no idea why... maybe a permission problem?
Laurent Gomila - SFML developer

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Example network program doesn't work on school network
« Reply #11 on: October 22, 2013, 09:06:01 pm »
Only thing I could find on google that might help is this.

Quote
Use 0 instead of IPPROTO_TCP

PPROTO_TCP (defined as 6 in winsock2.h) has never worked for me.
This totally contradicts the Microsoft docs, but it was the only way for me
to get it work (on XP!).

So what happens if you try that solution?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Example network program doesn't work on school network
« Reply #12 on: October 22, 2013, 09:38:55 pm »
Seriously... do people not read what has already been posted? I think it is clear that the call to socket() fails and the test program never gets to setsockopt()? So your advice makes no sense.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Example network program doesn't work on school network
« Reply #13 on: October 22, 2013, 09:46:43 pm »
I will admit I didn't read the entire code, but think about it. Maybe if one define is causing issues in one call, maybe another define is causing other issues. After all that is what the error is, "WSAEINVAL (10022): Invalid argument".

I'm also curious to know if the school computers in question happen to be running Windows XP  ;)
« Last Edit: October 22, 2013, 09:48:57 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Example network program doesn't work on school network
« Reply #14 on: October 22, 2013, 09:50:27 pm »
A quick search gave a few hints: it might be a permission issue (try to run the app with admin privileges, or from another drive) or the antivirus somehow interfering (try to disable it).
Laurent Gomila - SFML developer