[linux_var] Mezzora d'amicizia

HelLViS69 elvismetal a libero.it
Lun 27 Set 2004 16:53:25 UTC


#include <stdio.h>
#include <sys/socket.h>

int s;
struct hostent *server_host;
struct in_addr server_host_addr;
struct sockaddr_in server_addr;

// Socket
s = socket(AF_INET, SOCK_STREAM, 0);
if (s<0) {
    perror("socket() ");
    exit(1);
}

// Connect
server_host = gethostbyname("localhost");
if (!server_host) {
    perror("gethostbyname() ");
    exit(2);
}

bcopy(server_host->h_addr, &server_host_addr, server->h_lenght);

server_addr.sin_family=AF_INET;
server_addr.sin_port=htons(12345);
bcopy(&server_host_addr, &server_addr.sin_addr, sizeof(server_host_addr));

if (connect(s, &server_addr, sizeof(server_addr))==-1) {
    perror("connect() ");
    exit(3);
}

------
# gcc client.c -o client
client.c:10: initializer element is not constant
client.c:10: warning: data definition has no type or storage class
client.c:11: parse error before "if"
client.c:13: parse error before numeric constant
client.c:13: warning: data definition has no type or storage class
client.c:17: conflicting types for `server_host'
client.c:5: previous declaration of `server_host'
client.c:17: initializer element is not constant
client.c:17: warning: data definition has no type or storage class
client.c:18: parse error before "if"
client.c:20: parse error before numeric constant
client.c:20: warning: data definition has no type or storage class
client.c:23: parse error before '->' token
client.c:23: warning: data definition has no type or storage class
client.c:25: parse error before '.' token
client.c:27: parse error before '&' token
client.c:31: parse error before numeric constant
client.c:31: warning: data definition has no type or storage class
client.c:6: storage size of `server_host_addr' isn't known
client.c:7: storage size of `server_addr' isn't known


Xk mi da tutti quegli errori? dove sbaglio?

HelLViS69
-- 
Poich siamo costretti tra le sbarre di una prigione
la nostra non  la disdicevole fuga
del disertore di fronte al nemico,
ma la legittima evasione del prigioniero...



More information about the Talking mailing list