#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    9
    Rep Power
    0

    Unhappy C Socket programming in windows.


    hi there ppl.. well i just startet learning C read this book.. Teach yourself C in 21 days hehe :) well i loved it and well want too do something. and well i think developing somekind of client/server program would be fun..but im very limitet on funds for books and whatso ever.. and wondering if any of your ppl might have any help for me like a good link or a e-book you could send me...on the subject "socket programming in windows" and yes i have no idea whatsoever how too ive looked on a few sources codes that couldent even be compiled :( plz help me would be apreciatet..




    //ovre and out soul12
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    Search around here for 'socket' and 'windows', you should find some examples. You will have to be sure to include the networking headers and libraries when you compile. If you don't yet know how to do that, you will have to try to find a complete project that compiles. Put some research effort into it before asking for more help, after all, that is how we all got started.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    http://tangentsoft.net/wskfaq/
    and do a search for "beej's socket tutorial"
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    9
    Rep Power
    0

    thnx


    thnx for the link...and i did doo my research on this forum just got tired after looking trough page 4 and google..turned blank on this 1...only unix code..and since im new dident help me much..so asking you guys hoping for you too help me on..i cant be the only 1 with this problem so..
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,156
    Rep Power
    2222
    Although they are far from complete, I've started putting some pages up on the Web on sockets programming starting at http://members.aol.com/DSC30574/sockets/index.html . My resources page at http://members.aol.com/DSC30574/sockets/resources.html lists a number of compilers, books, and web sites, including Beej's which is good but which doesn't really deal with Winsock. My own page on Winsock programming is at http://members.aol.com/DSC30574/sockets/winsock.html and also contains links to other Winsock resources.

    Now, the thing about Winsock vs UNIX in network programming is that almost all of the UNIX functions are supported in Winsock. So except for some very UNIX-specific things like forking processes, you can take a UNIX sockets program and convert it over to Winsock with only a few changes. So what you learn on those sites that deal with UNIX sockets programming is almost directly applicable to Winsock programming.

    For that matter, here's my basic how-to straight off my page:
    Changing a UNIX sockets program to Winsock requires an amazingly small number of changes. The basic steps required to convert a UNIX sockets program to WinSock for Win32 are:

    1. Link the WinSock library, wsock32.lib, to your project. This is the library name in Visual C++; if you use a different compiler then verify the library name it uses.

    2. Replace the UNIX-specific header includes with the single include statement:
    #include <winsock.h>

    3. Within the program, run the Winsock initialization with the following code:
    a. Include the data declaration:
    WSADATA wsaData;

    b. Add the function call and completion test:
    if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0)
    {
    // insert error-handling code here
    }

    The parameter, MAKEWORD(2, 0), specifies the WinSock version number (version 2.0 in this example) and formats it correctly.

    4. Replace the UNIX close() function call with closesocket().

    5. At the end of the program, exit the WinSock DLL by calling the function, WSACleanup().

    6. Read error codes with WSAGetLastError().
    Complete instructions with pictures for creating in Visual C++ a Win32 console application (equivalent to a DOS application) that supports WinSock can be found in the PDF file, "Transitioning from UNIX to Windows Socket Programming," by Paul O'Steen, http://cs.baylor.edu/~donahoo/practi...owsSockets.pdf .

    An excellent book for getting started with sockets programming is "The Pocket Guide to TCP/IP Sockets: C Version" by Michael J. Donahoo and Kenneth L. Calvert (second edition title is "TCP/IP Sockets in C: Practical Guide for Programmers"). $15. While they deal entirely in UNIX, that information is almost directly applicable to Winsock. On their site they have both the source code of their UNIX examples (http://cs.baylor.edu/~donahoo/Pocket.../textcode.html ) and of the same programs converted over to Winsock (http://cs.baylor.edu/~donahoo/PocketSocket/winsock.html ).

    There are a few compatibility issues in Winsock, so you should also visit the Winsock Programmer's FAQ at http://tangentsoft.net/wskfaq/ . Besides answers to the frequently asked questions, it also contains articles and sample programs. Of particular interest in the matter of compatibility issues is the article, "Winsock's Compatibility With BSD Sockets", at http://tangentsoft.net/wskfaq/articl...atibility.html .
    Last edited by dwise1_aol; September 25th, 2003 at 03:07 PM.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    9
    Rep Power
    0
    should keep me reading a bit..keep em coming :)

IMN logo majestic logo threadwatch logo seochat tools logo