Solved

Socket programming compile error

Posted on 2004-08-04
4
609 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now