• Winsock2 woes

    From Xucaen@VERT/TIMEPORT to All on Wed Nov 25 14:17:53 2015
    Well, my project is dead in the water until I can find another way to convert an int into a socket. Does anyone know of a third party lib I can use in visual c that handles converting ints to sockets?

    ---
    ■ Synchronet ■ The Time Portal - timeport.synchro.net:2112 - Celebrating the past from the futu
  • From Digital Man@VERT to Xucaen on Wed Nov 25 20:13:52 2015
    Re: Winsock2 woes
    By: Xucaen to All on Wed Nov 25 2015 02:17 pm

    Well, my project is dead in the water until I can find another way to convert an int into a socket. Does anyone know of a third party lib I can use in visual c that handles converting ints to sockets?

    A socket descriptor is an integer (both on Windows and *nix). This is from winsock.h:

    typedef u_int SOCKET;

    Perhaps if you posted some sample code or more details about exactly what you're having an issue with, we could help. We've done this stuff before. :-)

    digital man

    Synchronet "Real Fact" #36:
    Synchronet's Windows Control Panel is built with Borland C++ Builder.
    Norco, CA WX: 50.7°F, 67.0% humidity, 0 mph E wind, 0.00 inches rain/24hrs

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ telnet://vert.synchro.net
  • From Xucaen@VERT/TIMEPORT to Digital Man on Thu Nov 26 10:01:39 2015
    Re: Winsock2 woes
    By: Xucaen to All on Wed Nov 25 2015 02:17 pm

    Well, my project is dead in the water until I can find another way to convert an int into a socket. Does anyone know of a third party lib I can use in visual c that handles converting ints to sockets?

    A socket descriptor is an integer (both on Windows and *nix). This is from >winsock.h:

    typedef u_int SOCKET;

    Perhaps if you posted some sample code or more details about exactly what >you're having an issue with, we could help. We've done this stuff before. :-)


    Hi DM (may I call you DM? ;)



    I have this at the top of my source file:

    #pragma comment(lib, "Ws2_32.lib")
    #include <WinSock2.h>



    Then I have a function that writes data to the socket


    void IOHandler::writeBytes(string line) const
    {
    cout << line;// << endl;


    if (dropfile->commType == 0)
    {
    cout << line;
    }
    else if (dropfile->commType == 2)
    {
    int bytes = ::send((SOCKET)dropfile->handle, line.c_str(), strlen(line.c_str()), 0);
    }
    }


    Then, I set up the program as a door using DOOR32.SYS.
    I verified my read function reads the file correctly and
    in my first test I got a socket handle 1480.

    in SCFG I pass the door file path using %f on the command line, no IO redirection, Native Executable Yes.

    When I telnet in from my other PC using SyncTerm, the game loads on the server but SyncTerm shows a blank screen
    but when I run the game locally I see the correct output.


    Google give me conflicting information, due to there being a winsock and a winsock2, but the above example was the best I could find using Winsock2

    ---
    ■ Synchronet ■ The Time Portal - timeport.synchro.net:2112 - Celebrating the past from the futu
  • From Xucaen@VERT/TIMEPORT to Xucaen on Thu Nov 26 10:26:27 2015
    Re: Winsock2 woes
    By: Xucaen to All on Wed Nov 25 2015 02:17 pm


    void IOHandler::writeBytes(string line) const
    {
    cout << line;// << endl;


    if (dropfile->commType == 0)
    {
    cout << line;
    }


    ignore that first cout, that was a cut and paste error on my part when pasting the code into the text box in my browser.

    ---
    ■ Synchronet ■ The Time Portal - timeport.synchro.net:2112 - Celebrating the past from the futu
  • From Digital Man@VERT to Xucaen on Thu Nov 26 11:53:17 2015
    Re: Winsock2 woes
    By: Xucaen to Digital Man on Thu Nov 26 2015 10:01 am

    Re: Winsock2 woes
    By: Xucaen to All on Wed Nov 25 2015 02:17 pm

    Well, my project is dead in the water until I can find another way to convert an int into a socket. Does anyone know of a third party lib I can use in visual c that handles converting ints to sockets?

    A socket descriptor is an integer (both on Windows and *nix). This is from >winsock.h:

    typedef u_int SOCKET;

    Perhaps if you posted some sample code or more details about exactly what >you're having an issue with, we could help. We've done this stuff before. :-)


    Hi DM (may I call you DM? ;)

    Yes, lots of sysops do. :-)

    I have this at the top of my source file:

    #pragma comment(lib, "Ws2_32.lib")
    #include <WinSock2.h>



    Then I have a function that writes data to the socket


    void IOHandler::writeBytes(string line) const
    {
    cout << line;// << endl;


    if (dropfile->commType == 0)
    {
    cout << line;
    }
    else if (dropfile->commType == 2)
    {
    int bytes = ::send((SOCKET)dropfile->handle, line.c_str(), strlen(line.c_str()), 0);
    }
    }


    Then, I set up the program as a door using DOOR32.SYS.
    I verified my read function reads the file correctly and
    in my first test I got a socket handle 1480.

    in SCFG I pass the door file path using %f on the command line, no IO redirection, Native Executable Yes.

    When I telnet in from my other PC using SyncTerm, the game loads on the server but SyncTerm shows a blank screen
    but when I run the game locally I see the correct output.

    Are you calling WSAStartup()?

    Did you check the return value of send()?

    Have you looked at any working example code (e.g. sbbs/xtrn/sdk)?

    digital man

    Synchronet "Real Fact" #33:
    The back-up synchro.net nameserver and CVS repository is hosted by Deuce. Norco, CA WX: 57.2°F, 50.0% humidity, 1 mph SE wind, 0.00 inches rain/24hrs

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ telnet://vert.synchro.net
  • From Deuce@VERT/SYNCNIX to Xucaen on Thu Nov 26 13:17:49 2015
    Re: Winsock2 woes
    By: Xucaen to All on Wed Nov 25 2015 02:17 pm

    Well, my project is dead in the water until I can find another way to convert an int into a socket. Does anyone know of a third party lib I can use in visual c that handles converting ints to sockets?

    There's OpenDoors. http://cvs.synchro.net/cgi-bin/viewcvs.cgi/src/odoors/?view=tar

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    Mro is an idiot. Please ignore him, we keep hoping he'll go away.
    ■ Synchronet ■ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Xucaen@VERT/TIMEPORT to Digital Man on Thu Nov 26 18:26:51 2015
    Are you calling WSAStartup()?

    Call him? I never met him! (Sorry, a bit of humor)

    I will look into that.



    Did you check the return value of send()?


    At one point it was returning the correct number of bytes I was expecting.



    Have you looked at any working example code (e.g. sbbs/xtrn/sdk)?



    I don't have an sdk directory so I'll have to go get it, I haven't yet.



    Sorry if the quoting in this message if messed up. I'm entering this on my Android phone.

    ---
    ■ Synchronet ■ The Time Portal - timeport.synchro.net:2112 - Celebrating the past from the futu
  • From Xucaen@VERT/TIMEPORT to Digital Man on Thu Nov 26 20:32:34 2015
    Re: Winsock2 woes
    By: Xucaen to Digital Man on Thu Nov 26 2015 10:01 am

    #pragma comment(lib, "Ws2_32.lib")
    #include <WinSock2.h>



    Then I have a function that writes data to the socket


    void IOHandler::writeBytes(string line) const
    {

    if (dropfile->commType == 0)
    {
    cout << line;
    }
    else if (dropfile->commType == 2)
    {
    int bytes = ::send((SOCKET)dropfile->handle, line.c_str(), strlen(line.c_str()), 0);
    }
    }




    Are you calling WSAStartup()?



    That was it. I am now sending data over the socket. Now the real work begins. ;-)

    Thanks you so much! I think when I am done I am going to document what I did and spread the word far and wide. (there were a few people askign the same questions as I on Stack Exchange and the answer always seems to be "you can't with winsock". Well, we proved them wrong. \o/

    Have a great evening!

    ---
    ■ Synchronet ■ The Time Portal - timeport.synchro.net:2112 - Celebrating the past from the futu
  • From Xucaen@VERT/TIMEPORT to All on Fri Nov 27 12:28:31 2015
    This is interesting. According to the documentation I managed to find regarding the WSAStartup(), it says I also have to call WSACleanup().

    And according to this:

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms741549(v=vs.85).aspx?f=255

    ---
    ■ Synchronet ■ The Time Portal - timeport.synchro.net:2112 - Celebrating the past from the futu