Public feed
#602183
#include <stdio.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/sctp.h>
#include <sys/uio.h>
main()
{
struct sockaddr_in cad;
int alen;
int sd2;
char buf[1000];
struct sockaddr_in addr;
memset((char *)&addr, 0, sizeof(addr)); /* clear sockaddr structure */
addr.sin_family = PF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(6654);
int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
if(bind(sd, (struct sockaddr *)&addr,sizeof(addr) )==-1){
printf("bind_error\n");exit(1);
}
else printf("binded\n");
if (listen(sd, 1)==-1) {
printf("listen");
exit(1);
}
else printf("listening...\n");
for (;;) {
alen = sizeof(cad);
if ( ( sd2 = accept(sd, (struct sockaddr *)&cad, &alen)) < 0) {
fprintf(stderr, "Accept failed\n");
exit(1);
}
recv(sd2,buf,sizeof(buf),0);
printf("\nData received from guest ");
}
}