Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2006
    Messaggi
    144

    [C] socket() su mac

    Ciao!

    vorrei far andare questo codice su mac:

    codice:
    #include<stdio.h>
    #include<stdlib.h>
    #include<sys/socket.h>
    #include<features.h>
    #include<linux/if_packet.h>
    #include<linux/if_ether.h>
    #include<errno.h>
    #include<sys/ioctl.h>
    #include<net/if.h>
    
    #define PACKET_LENGTH	1024
    
    
    int CreateRawSocket(int protocol_to_sniff)
    {
    	int rawsock;
    	
    	if((rawsock = socket(PF_PACKET, SOCK_RAW, htons(protocol_to_sniff)))== -1)
    	{
    		perror("Error creating raw socket: ");
    		exit(-1);
    	}
    	
    	return rawsock;
    }
    però non riconosce per esempio PF_PACKET perché ovviamente è definita in una libreria che nn c'è sul mac. Sapete voi che librerie dovrei usare?

    Grazie a chi cercherà di rispondermi.

  2. #2

    Re: [C] socket() su mac

    codice:
    $ man socket
    SOCKET(2)                   BSD System Calls Manual                  SOCKET(2)
    
    NAME
         socket -- create an endpoint for communication
    
    SYNOPSIS
         #include <sys/socket.h>
    
         int
         socket(int domain, int type, int protocol);
    
    DESCRIPTION
         Socket() creates an endpoint for communication and returns a descriptor.
    
         The domain parameter specifies a communications domain within which communication will take place; this selects the protocol family which should be used.  These families are defined in
         the include file <sys/socket.h>.
    ...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.