Solved

Socket programming compile error

Posted on 2004-08-04
4
611 Views
Last Modified: 2010-05-18
Hello all!
I have some C code,as introduced ,it can be compiled in both Windows and Unix.But when i compile in Windows ,it compile fail because of its use "#include sys/socket.h" which is not of Windows socket programming API.The Complete include section is like :
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
...
What library should I install to compile(and link,of course) this code snippet?
Thanks in advance
0
Comment
Question by:Lara_tin2
  • 2
  • 2
4 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 11713085
Hi Lara_tin2,

use #include <winsock.h>

Sunnycoder
0
 
LVL 1

Author Comment

by:Lara_tin2
ID: 11713105
ok!I've tried it but very many error occur when I compile.
I want a header file sys/socket.h and coresponding lib file but dont know where to download it
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 100 total points
ID: 11713118
errors are due the linux specific functions that you may be using ... post the errors here ...

winsock.h is the file to use if you want to port it to windows ... If all you want is to be able to compile it on windows then download cygwin platform
http://www.cygwin.com/
0
 
LVL 1

Author Comment

by:Lara_tin2
ID: 11713151
Thanks!I will try it
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question