Solved

Socket programming compile error

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

706 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

22 Experts available now in Live!

Get 1:1 Help Now