I'm trying to compile a rather simple C program under Borlan'd C++ Builder 4 but it's not working. It can't find some libraries, mostly socket related ones. How can I fix this? (Yes, I want to program in C and not C++).
Here are the includes that can't be found
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
totsubo
Here's the full code if it helps:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
void usage(char *s)
{
printf("\n(c)2000 Marc Blumenauer <mob@system-security.net>\
n\n");
printf("%s <start_ip> <end_ip> <port>\n",s);
printf("\n");
exit(1);
}
int main(int argc, char *argv[])
{
int sockfd, n, ret;
struct hostent *he;
struct sockaddr_in she_addr;
int start,end;
char host[100];
int x1,x2,x3,port;
if(argc <= 3)
usage(argv[0]);
port = atoi(argv[3]);
sscanf(argv[1],"%d.%d.%d.%
d",&x1,&x2
,&x3,&star
t);
sprintf(host,"%d.%d.%d.%d"
,x1,x2,x3,
start);
printf("\nScanning TCP Port %d from <%s> to ",port,host);
sscanf(argv[2],"%d.%d.%d.%
d",&x1,&x2
,&x3,&end)
;
sprintf(host,"%d.%d.%d.%d"
,x1,x2,x3,
end);
printf("<%s>\n",host);
printf("\n");
for(;start <= end;start++)
{
sprintf(host,"%d.%d.%d.%d"
,x1,x2,x3,
start);
fflush(stdout);
sockfd=socket(AF_INET,SOCK
_STREAM,0)
;
bzero((char*)&she_addr,siz
eof(she_ad
dr));
she_addr.sin_family=AF_INE
T;
she_addr.sin_port=htons(po
rt);
she_addr.sin_addr.s_addr = inet_addr(host);
if((ret=connect(sockfd,&sh
e_addr,siz
eof(she_ad
dr)))!=-1)
printf("\n--> %s\n",host);
else
printf(".");
close(sockfd);
sleep(1);
}
printf("\n");
return 0;
}
Start Free Trial