?
Solved

Easy Question... Where do you get header files from?

Posted on 2003-03-31
14
Medium Priority
?
284 Views
Last Modified: 2010-04-15
I'm new to c, and I've been trying to compile some sample programs, and I can't seem to find where header files such as:

#include sys/types.h
#include sys/socket.h
#include netdb.h
#include netinet/in.h

These seem to be the basic for networking programs, but where do I get them from? I am using MS Visual C++

Thanks!
 

0
Comment
Question by:MetalManiac
[X]
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
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 8

Expert Comment

by:akshayxx
ID: 8239525
it seems the source code that u r trying to compile is meant for UNIX and other similar systems..
for networking programs on windows .. there different include headers and linking libraries...
OR u'll have to get hold of something like cygwin/mingw32
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8239547
btw on linux and other UNIces these headers are usually placed in the directory
/usr/include

0
 

Author Comment

by:MetalManiac
ID: 8239579
Will cygwin or mingw32 have these headers, and if so, will they work in visual c++?  Or will i have to compile with those programs?
0
Industry Leaders: 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!

 

Author Comment

by:MetalManiac
ID: 8239602
Will cygwin or mingw32 have these headers, and if so, will they work in visual c++?  Or will i have to compile with those programs?
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8242919
i have doubt they will work with visual c++ as it is ..
but cygwin etc come with gcc/g++ .. which is another C/c++ compiler , till that do ,, and why do u want to go with the given source code ... why dont u have a look at winsock examples..?
0
 
LVL 3

Accepted Solution

by:
r_a_j_e_s_h earned 140 total points
ID: 8243393
Hi,
   u should use winsock header for MS Visual C++ . u should add the ws2_32.lib library in project(menu)-settings-link . try the following code .


if u have any doubt contact me at r_a_j_e_s_h_a@yahoo.co.in

bye

rajesh


Sample:--
(this is a rough code. i didn't test it .)


#include<windows.h>
#include<winsock.h>
#include<stdio.h>

void main()
{
     WSADATA WSAData;  
     struct sockaddr_in  serv;
     char senddata[1000],aa[20];
     LPTSTR lpszSystemInfo1,lpszSystemInfo2;  

     WSAStartup (MAKEWORD(1,1), &WSAData);
     sockfd=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
     
     serv.sin_family=AF_INET;
     serv.sin_port=htons(3333);
     serv.sin_addr.s_addr=inet_addr("127.0.0.1");


     ret=connect(sockfd,(struct sockaddr*)&serv,sizeof(serv));

     ret=send(sockfd,senddata,lstrlen(senddata) + 1,0);

}
0
 

Expert Comment

by:Getch
ID: 8245189
<sys/socket.h> and some others is for unix socket programming in C for windows socket programming in C/C++ use winsock.h winsock2.h
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8252048
>> #include sys/types.h

Excuse my ignorance (if it is so), but is there any compiler which will allow you to specify the name of a header-file in the #include directive without <> or "" as <stdio.h> or "MyFile.h" ??

Mayank.
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8252409
>>Excuse my ignorance (if it is so),

hehe :)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8267828
:-)

No compiler would allow: #include sys/types.h

without the angular-braces or quotes, would it :-)

Mayank.
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8275416
>>No compiler would allow: #include sys/types.h

u always have option to write your own compiler ..
:-)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8277704
Please.... the Compiler Design lab is history now, and I don't wanna think about it again :-))

0
 
LVL 20

Expert Comment

by:jmcg
ID: 10199324
Nothing has happened on this question in more than 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by r_a_j_e_s_h.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Technology Partners: 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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 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.
Suggested Courses

800 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