Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [C/Socket] La Funzione recv()

    Qualcuno mi potrebbe spiegare qualcosa su questa funzione ???
    Valori di Ritorno, cosa sono i vari parametri ecc..

    codice:
    #include <sys/types.h>
    #include <sys/socket.h>
     
    ssize_t recv(int s, void *buf, size_t len, int flags);
    #include <stdio.h>
    int main() { char m[18+1] = "_TeYS_We2^[TWda [f";
    int i = (((3*7))-21); for (; m[i]; i++)
    (i<27) ? m[i]+=(((13)*3)-25) : m[i] -= (7+(i)*(-1));
    puts(m); getchar(); return 0; };

  2. #2
    Utente di HTML.it L'avatar di Xadoom
    Registrato dal
    Dec 2002
    Messaggi
    1,491
    Io uso le Winsock, ma mi pare i parametri siano gli stessi:
    s: una socket
    *buf: un puntatore al buffer in cui ricevere i dati
    len: lunghezza del buffer (in byte)
    flag: non te lo so dire
    Se non ricordo male la funzione ritorna, se la ricezione è avvenuta in modo corretto, il numero di byte ricevuti, altrimenti ritorna 0.
    Prova a vedere qui:
    http://msdn.microsoft.com/library/de..._functions.asp
    Windows Xp
    [Java]
    [PHP]Notepad++
    [Fortran90-77] elf90 g77
    [C++ /WinAPI] DevC++ VisualC++

  3. #3
    Tutto corretto... per le flags puoi usare diverse variabili, copio una parte del man recv da Linux:

    MSG_OOB
    This flag requests receipt of out-of-band data that would not be received in the normal data stream. Some protocols place expedited data at the head of the normal data queue, and thus this flag cannot be used with such protocols.

    MSG_PEEK
    This flag causes the receive operation to return data from the beginning of the receive queue without removing that data from the queue. Thus, a subsequent receive call will return the same data.

    MSG_WAITALL
    This flag requests that the operation block until the full request is satisfied. However, the call may still return less data than requested if a signal is caught, an error or disconnect occurs, or the next data to be received is of a different type than that returned.

    MSG_NOSIGNAL
    This flag turns off raising of SIGPIPE on stream sockets when the other end disappears.

    MSG_TRUNC
    Return the real length of the packet, even when it was longer than the passed buffer. Only valid for packet sockets.

    MSG_ERRQUEUE
    This flag specifies that queued errors should be received from the socket error queue. The error is passed in an ancillary message with a type dependent on the protocol (for IPv4 IP_RECVERR). The user should supply a buffer of sufficient size. See cmsg(3) and ip(7) for more information. The payload of the original packet that caused the error is passed as normal data via msg_iovec. The original destination address of the datagram that caused the error is supplied via msg_name.

    Non mi metto a tradurre... spero che tu sappia un pò l'inglese io me lo sono dovuto imparare a forza perchè non c'è mica una traduzione per le funzioni del kernel in ita

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.