Ticket #516: socket3.patch

File socket3.patch, 4.9 KB (added by bacek, 6 years ago)
  • examples/io/httpd.pir

    commit 998bb26a11e94089a1688673cb30bf9b4016ea7a
    Author: Vasily Chekalkin <bacek@bacek.com>
    Date:   Sat Mar 28 08:01:55 2009 +1100
    
        Change Parrot_io_socket to return INTVAL as all other functions
    
    diff --git a/examples/io/httpd.pir b/examples/io/httpd.pir
    index 01a596c..3970d37 100644
    a b  
    111111    port = 1234 
    112112 
    113113    # TODO provide sys/socket constants 
    114     .local pmc sock 
    115     sock = new 'Socket' 
    116     listener = sock.'socket'(2, 1, 6)   # PF_INET, SOCK_STREAM, tcp 
     114    listener = new 'Socket' 
     115    listener.'socket'(2, 1, 6)  # PF_INET, SOCK_STREAM, tcp 
    117116    unless listener goto ERR_NO_SOCKET 
    118117 
    119118    # Pack a sockaddr_in structure with IP and port 
    120     address = sock.'sockaddr'(host, port) 
     119    address = listener.'sockaddr'(host, port) 
    121120    ret = listener.'bind'(address) 
    122121    if ret == -1 goto ERR_bind 
    123122    $S0 = port 
  • include/parrot/io.h

    diff --git a/include/parrot/io.h b/include/parrot/io.h
    index 2efc85b..54fcaaf 100644
    a b  
    829829PARROT_EXPORT 
    830830PARROT_WARN_UNUSED_RESULT 
    831831PARROT_CANNOT_RETURN_NULL 
    832 PMC * Parrot_io_socket(PARROT_INTERP, 
     832INTVAL Parrot_io_socket(PARROT_INTERP, 
    833833    ARGMOD_NULLOK(PMC * socket), 
    834834    INTVAL fam, 
    835835    INTVAL type, 
  • include/parrot/io_unix.h

    diff --git a/include/parrot/io_unix.h b/include/parrot/io_unix.h
    index 307f94c..90a3c7e 100644
    a b  
    220220 
    221221PARROT_WARN_UNUSED_RESULT 
    222222PARROT_CAN_RETURN_NULL 
    223 PMC * Parrot_io_socket_unix(PARROT_INTERP, 
     223INTVAL Parrot_io_socket_unix(PARROT_INTERP, 
    224224    ARGIN(PMC *s), 
    225225    int fam, 
    226226    int type, 
  • include/parrot/io_win32.h

    diff --git a/include/parrot/io_win32.h b/include/parrot/io_win32.h
    index b39d8fd..489c819 100644
    a b  
    199199 
    200200PARROT_WARN_UNUSED_RESULT 
    201201PARROT_CAN_RETURN_NULL 
    202 PMC * Parrot_io_socket_win32(PARROT_INTERP, 
     202INTVAL Parrot_io_socket_win32(PARROT_INTERP, 
    203203    ARGIN(PMC * s), 
    204204    int fam, 
    205205    int type, 
  • src/io/socket_api.c

    diff --git a/src/io/socket_api.c b/src/io/socket_api.c
    index d148018..976a0cb 100644
    a b  
    6969 
    7070/* 
    7171 
    72 =item C<PMC * Parrot_io_socket> 
     72=item C<INTVAL Parrot_io_socket> 
    7373 
    7474Creates and returns a socket using the specified address family, socket type, 
    7575and protocol number. Check the returned PMC with a boolean test to see whether 
     
    8282PARROT_EXPORT 
    8383PARROT_WARN_UNUSED_RESULT 
    8484PARROT_CANNOT_RETURN_NULL 
    85 PMC * 
     85INTVAL 
    8686Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC * socket), INTVAL fam, 
    8787            INTVAL type, INTVAL proto) 
    8888{ 
  • src/io/socket_unix.c

    diff --git a/src/io/socket_unix.c b/src/io/socket_unix.c
    index 1362e62..f716281 100644
    a b  
    115115 
    116116/* 
    117117 
    118 =item C<PMC * Parrot_io_socket_unix> 
     118=item C<INTVAL Parrot_io_socket_unix> 
    119119 
    120120Uses C<socket()> to create a socket with the specified address family, 
    121121socket type and protocol number. 
     
    126126 
    127127PARROT_WARN_UNUSED_RESULT 
    128128PARROT_CAN_RETURN_NULL 
    129 PMC * 
     129INTVAL 
    130130Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto) 
    131131{ 
    132132    ASSERT_ARGS(Parrot_io_socket_unix) 
     
    136136        setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i)); 
    137137        Parrot_io_set_os_handle(interp, s, sock); 
    138138        SOCKADDR_REMOTE(s)->sin_family = fam; 
    139         return s; 
     139        return 0; 
    140140    } 
    141     return PMCNULL; 
     141    return -1; 
    142142} 
    143143 
    144144/* 
  • src/io/socket_win32.c

    diff --git a/src/io/socket_win32.c b/src/io/socket_win32.c
    index b458313..4879e99 100644
    a b  
    6161 
    6262/* 
    6363 
    64 =item C<PMC * Parrot_io_socket_win32> 
     64=item C<INTVAL Parrot_io_socket_win32> 
    6565 
    6666Uses C<socket()> to create a socket with the specified address family, 
    6767socket type and protocol number. 
     
    7272 
    7373PARROT_WARN_UNUSED_RESULT 
    7474PARROT_CAN_RETURN_NULL 
    75 PMC * 
     75INTVAL 
    7676Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto) 
    7777{ 
    7878    ASSERT_ARGS(Parrot_io_socket_win32) 
     
    8282        setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i)); 
    8383        Parrot_io_set_os_handle(interp, s, sock); 
    8484        SOCKADDR_REMOTE(io)->sin_family = fam; 
    85         return io; 
     85        return 0; 
    8686    } 
    87     return PMCNULL; 
     87    return -1; 
    8888} 
    8989 
    9090/*