Plazo de entrega: Miércoles 14 de Junio 17:00 horas en pañol de electrónica.
s = socket(PF_INET, SOCK_STREAM, 0); /* Create the socket. */
name.sin_family = AF_INET;
/* Create the address of the server. */
name.sin_port = htons(PORTNUMBER);
name.sin_addr.s_addr = htonl(INADDR_ANY);
/* Use the wildcard address.*/
len = sizeof(struct sockaddr_in);
bind(s, (struct sockaddr *) &name, len);
/* Bind the socket to the address. */
listen(s, 5); /* Listen for connections.
*/
ns = accept s,(struct scoket *) &name, &len);
/* Accept a connection */
while ((n = recv(ns, buf, sizeof(buf), 0)) > 0)
/* Read from the socket until */
write(stdout, buf, n);
/* end-of-file and print what we get on the standard output.
*/
close(ns);
close(s);
}