Fichero /opt3/ro/ficheros/sockpromis/ejemplos/ejemplo1.c:
#include <stdio.h>
#include <sockpromis.h>
print_packet(char * buf, int tam)
{
int i;
for (i=0;(i<tam)&&(i<80);i++)
printf("%x ", buf[i]&0xff);
printf("\n");
}
main()
{
int s;
char buf[3000];
int tam;
s=sp_new_sock();
if (s==-1) exit(-1);
tam=sp_recv(s,buf,3000);
if (tam==-1) exit(-1);
print_packet(buf,tam);
}
Compilación:
[]% gcc /opt3/ro/ficheros/sockpromis/ejemplos/ejemplo1.c -I/opt3/ro/ficheros/sockpromis/include -L/opt3/ro/ficheros/sockpromis/lib -lsockpromis -o ejemplo_sockpromis