Changeset 0f88a225


Ignore:
Timestamp:
Dec 3, 2020, 3:19:37 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
27b1ca1, aeb31b1
Parents:
fe9468e2
Message:

updated out-of-date example echo network server

File:
1 edited

Legend:

Unmodified
Added
Removed
  • example/io/simple/server.cfa

    rfe9468e2 r0f88a225  
    1313#include <time.hfa>
    1414#include <thread.hfa>
     15#include <concurrency/iofwd.hfa>
    1516
    1617//----------
     
    2122}
    2223
    23 void message( Printer & mutex, char * msg, size_t len ) {
    24         fprintf(stderr, "'%.*s'", len, msg);
     24void message( Printer & mutex, char * _msg, size_t len ) {
     25        fprintf(stderr, "'%.*s'", len, _msg);
    2526}
    2627
     
    2930}
    3031
    31 void error( Printer & mutex, const char * msg, int error) {
    32         fprintf(stderr, "%s - %s\n", msg, strerror(error));
     32void error( Printer & mutex, const char * _msg, int error) {
     33        fprintf(stderr, "%s - %s\n", _msg, strerror(error));
    3334}
    3435
     
    4950        }
    5051}
    51 
    52 //----------
    53 extern ssize_t cfa_recvmsg(int sockfd, struct msghdr *msg, int flags);
    54 extern int cfa_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
    55 extern int cfa_close(int fd);
    5652
    5753//----------
     
    8884        struct sockaddr_in cli_addr;
    8985        __socklen_t clilen = sizeof(cli_addr);
    90         int newsock = cfa_accept4(sock, (struct sockaddr *) &cli_addr, &clilen, 0);
     86        int newsock = cfa_accept4(sock, (struct sockaddr *) &cli_addr, &clilen, 0, 0, -1`s, 0p, 0p);
    9187        if (newsock < 0) {
    9288                error( printer, "accept", -newsock);
     
    9793
    9894        while(1) {
    99                 int res = cfa_recvmsg(newsock, &msg, 0);
     95                int res = cfa_recvmsg(newsock, &msg, 0, 0, -1`s, 0p, 0p);
    10096                if(res == 0) break;
    10197                if(res < 0) {
     
    107103        }
    108104
    109         ret = cfa_close(newsock);
     105        ret = cfa_close(newsock, 0, -1`s, 0p, 0p);
    110106      if(ret < 0) {
    111107            error( printer, "close new", -ret);
     
    113109      }
    114110
    115         ret = cfa_close(sock);
     111        ret = cfa_close(sock, 0, -1`s, 0p, 0p);
    116112      if(ret < 0) {
    117113            error( printer, "close old", -ret);
Note: See TracChangeset for help on using the changeset viewer.