witam
napisalem sobie bota irc w c++, niestety nie chce mi sie skompilowac pod fbsd, pod linux ladnie sie kompiluje i spoko dziala. Nie bede wklejal calego kodu bota ale tylko to co robi blad
Tu jest blad zwracany przez kompilator:
simple.cpp: In function int main()': simple.cpp:24: error: aggregate
sockaddr_in saddr' has incomplete type and
cannot be defined
simple.cpp:54: error: `htons' undeclared (first use this function)
simple.cpp:54: error: (Each undeclared identifier is reported only once for
each function it appears in.)
a tu jest prosty kodzik siecowki ktora laczy sie z ftp, tez nie chce sie skompilowac i zwraca ten sam error, gdzie jest bald??
#include <sys/types.h>
#include <sys/socket.h> /* socket(), connect(), recv(), send() /
#include <sys/stat.h> / S_IRUSR, S_IWUSR /
#include <fcntl.h> / open() /
#include <unistd.h> / close(), write() /
#include <stdio.h> / perror() /
#include <netdb.h> / getservbyname() /
#include <string> / strncmp() */
#include <stdlib.h>
using namespace std;
int main()
{
/********************** ZMIENNE DLA GNIAZDA **/
int fd,
sd,
ret;
long int msgsize,
msize;
struct sockaddr_in saddr;
struct servent srvent;
struct hostent sent;
char buf[2048];
char bufbig[2048];
/ ZMIENNE DLA GNIAZDA **********************/
char *server;
int port;
server="ftp.members.lycos.co.uk";
port=21;
sd = socket (PF_INET, SOCK_STREAM, 0);
if (sd < 0)
{
perror ("socket()");
exit (1);
}
sent = gethostbyname (server);
if (!sent)
{
herror ("gethostbyname()");
exit (1);
}
saddr.sin_family = sent->h_addrtype;
saddr.sin_port = srvent->s_port;
bcopy (sent->h_addr, (char *) &saddr.sin_addr, sent->h_length);
saddr.sin_port=htons(port);
ret = connect (sd, (struct sockaddr *) &saddr, sizeof (saddr));
if (ret < 0)
{
perror ("connect()");
exit (1);
}
else
printf ("Polaczony.\n");
bzero(buf,sizeof(buf));
recv(sd,buf,sizeof(buf),0);
printf("%s\n",buf);
return 0;
}