Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Socket programming compile error

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
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.

856 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