Network Programming in C for Windows

This is a discussion on Network Programming in C for Windows within the C Programming forums, part of the General Programming Boards category; First of all, I'd like to thank everyone who participates in this forum. I've been reading some of the posts ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    20

    Network Programming in C for Windows

    First of all, I'd like to thank everyone who participates in this forum. I've been reading some of the posts for a while, but not posted myself until now. Everyone who so freely offers their information is makes this forum so great.

    Anyways to my question. I'm trying to learn to do network programming, in C, in Windows. I've scrounged around the "Network Programming" forum, and there's some good info in there. But most of the Windows programming is in C++. I downloaded Beej's Guide to Network Programming, and it's also got some good info, for C. But its for linux.

    Currently, the computer I use the most is my laptop. I use it because when I travel, I can take it with me. I currently have a desktop running linux, and have tried one of Beej's examples. I like it very much, but I do most of my programming on my Windows Laptop. So my delima is, learning to program network stuff, in C, on Windows.

    Is there a good starter tutorial to suit my needs? Beej mentioned the modifications needed to adapt his tutorial to Windows, but I'm not sure if i'm doing it right. If anyone knows a good windows tutorial, or could help me adapt my code from beej to work with windows, i'd be very greatful.

    Thank you to everyone,
    Michael

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,162
    I believe most of the standard functions (e.g. socket(), bind(), listen(), etc.) will work on your favorite win32 compiler using the winsock(2) library. You just need to call WSAStartup() before using any of those functions. And don't forget to call WSACleanup() before your program exits.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    20
    I tried Johnnys winsock, but I get a bunch of linker errors when I try to compile.

    Using Dev-C++ for compiling.

    I've tried using the code straight from the tutorial, and I downloaded the zip file with all the source code. Still not working, any ideas?

  5. #5
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Quote Originally Posted by m.mixon
    I tried Johnnys winsock, but I get a bunch of linker errors when I try to compile.

    Using Dev-C++ for compiling.

    I've tried using the code straight from the tutorial, and I downloaded the zip file with all the source code. Still not working, any ideas?
    Linker errors mean you haven't linked the right libraries. Go to Project Options from the Project menu. Then go to the Parameters tag, click add library or object. Then select libws2_32.lib (or libwsock32.lib if youre using 1.1). It should compile properly after you've done this.

  6. #6
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I think it's either libws2_32.a or ws2_32.lib

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    20
    awsome. That worked. Do I have to do that for every program I write that uses networking stuff??

  8. #8
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,162
    Quote Originally Posted by m.mixon
    awsome. That worked. Do I have to do that for every program I write that uses networking stuff??
    Yes.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3D Network Analysis Tool
    By durban in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 11-08-2005, 05:33 PM
  2. Need help with easy Network setup
    By the dead tree in forum Tech Board
    Replies: 9
    Last Post: 04-08-2005, 07:44 PM
  3. network problems
    By lucy in forum Tech Board
    Replies: 6
    Last Post: 01-01-2003, 02:33 PM
  4. WinXP Network Connections pop-up
    By DavidP in forum Tech Board
    Replies: 1
    Last Post: 10-02-2002, 05:36 PM
  5. Network problem
    By dirkduck in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 07-26-2002, 12:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21