FYI
Following code working fine on linux, but not working on mac.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(void) {
int i, recv_length, sockfd;
u_char buffer[9000];
printf("Opening socket\n");
if ((sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP)) == -1) {
printf("Socket failed!!\n");
return -1;
}
printf("Socket opened\n");
for(i=0; i < 3; i++) {
printf("Going to read i: %d\n", i);
recv_length = recv(sockfd, buffer, 8000, 0);
printf("Got some bytes : %d\n", recv_length);
}
return 0;
}
Topic:
App & System Services
SubTopic:
Core OS
Tags: