Código:
niknitrodeb@debian:~$ gcc '/var/run/vmblock-fuse/blockdir/2d4962c9/EchoServer.cpp'
/tmp/ccLr8loR.o: In function `__static_initialization_and_destruction_0(int, int)':
EchoServer.cpp:(.text+0x11c): undefined reference to `std::ios_base::Init::Init()'
EchoServer.cpp:(.text+0x121): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccLr8loR.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Aquí teneis mi código:
Código
#include <iostream> #include <sys/socket.h> #include <unistd.h> //Otros includes: #include<netinet/in.h> #include<arpa/inet.h> #include<netdb.h> #include<string.h> using namespace std; int listen_socket, cliente; struct sockaddr_in clientinfo, server; int rtn; char buffer[256]; const int PUERTO = 5050; int main() { //SOCKET listen_socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); server.sin_family = PF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(PUERTO); //BIND rtn = bind(listen_socket, (struct sockaddr*) (&server), (int) sizeof(server)); //LISTEN listen(listen_socket, 1); //1 es el maximo de conexiones a la vez //ACCEPT cliente = accept(listen_socket, (struct sockaddr*) (&server), (socklen_t*) (sizeof(struct sockaddr_in)));// No estoy seguro de que sea socklen_t*. En las tansparencias pone int //READ // rtn = read(listen_socket, (*buffer), sizeof(buffer)); rtn = recv(cliente, buffer, 256, 0); while (true) { //WRITE // rtn = write(listen_socket, (*buffer), sizeof(buffer)); write(cliente, buffer, strlen(buffer)); //READ // rtn = read(listen_socket, (*buffer), sizeof(buffer)); rtn = recv(cliente, buffer, 256, 0); // printf("Bucle"); } return 0; }
Alguna ayudita?
Saludos;)
EDITO: Puede ser que debiera usar g++ en vez de gcc??