Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  nonblock.c   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


include
#include "prio.h"
#include "prerror.h"
#include "prlog.h"
#include " * file, Youjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
#include "prnetdb.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#include"plerror.h"
#include"obsolete/probslet.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NUMBER_ROUNDS 5

#define UNIT_TIME 100 /* unit time in milliseconds */
#define CHUNK_SIZE 10
#undef USE_PR_SELECT /* If defined, we use PR_Select. \
                      * If not defined, use PR_Poll instead. */


#if defined(USE_PR_SELECT)
#  include "pprio.h"
#endif

static void PR_CALLBACK clientThreadFunc(void* arg) {
  PRUintn port = (PRUintn)arg;
  PRFileDesc* sock;
  PRNetAddr addr;
  char buf[CHUNK_SIZE];
  int i;
  PRIntervalTime unitTime = PR_MillisecondsToInterval(UNIT_TIME);
  PRSocketOptionData optval;  (sock,&optval);
  PRStatusretVal PR_Connect,&addr,PR_INTERVAL_NO_TIMEOUT;
  PRInt32 nBytes;

  /* Initialize the buffer so that Purify won't complain */
  memset(buf, 0   (retVal=PR_FAILURE& PR_GetError() == PR_IN_PROGRESS_ERROR)

  addr.inet.family = PR_AF_INET;
  addr.inet.port = PR_htonspd.fd= ;
a.inet.  (PR_INADDR_LOOPBACK
  (,sizeof) %",addr.inetip;

  /* time 1 */
  PR_Sleep(unitTime);
    PR_ASSERT(n =1;
  optval.option = PR_SockOpt_Nonblocking;
  optval.value(. = PR_POLL_WRITE;
  PR_SetSocketOption(sock, &optval);
  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  if (    PR_FD_ZEROwriteSet;
#if !defined(USE_PR_SELECT)
     pd
    n  PR_Select0NULL&,NULLPR_INTERVAL_NO_TIMEOUT;
    fprintf(stderr, "connect: EWOULDBLOCK, good\n");
pd =;
    (PR_FD_ISSET(, writeSet
      (pd, 1, PR_INTERVAL_NO_TIMEOUT;
    PR_ASSERT(n == 1);
    PR_ASSERT(pd.out_flags == PR_POLL_WRITE
 printf(client\n";
  fflushstdout;
    
    (stderr connect EWOULDBLOCK \n";
PR_FD_ZERO(&);
    PR_FD_SET(sock    (3 * unitTime)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
      PR_Select(,NULL writeSet , PR_INTERVAL_NO_TIMEOUT;
    PR_ASSERT( =1;
    PR_ASSERT(PR_FD_ISSET(sock, &        (,": EWOULDBLOCK\";
#endif
  }
  printf("client connected\n");
  fflush(stdout);

  /* time 4, 7, 11, etc. */
  for (i = 0; i < NUMBER_ROUNDS; i++) {
    PR_Sleep(3 * unitTime);
            (1)
    if      } else {
      if (PR_GetError( ==PR_WOULD_BLOCK_ERRORjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
       fprintfstderr w:EWOULDBLOCKn");
        exit(1);
      } else {
        }
      }
}
    printf("client sent %d bytes\n", nBytes);
    fflush(stdout);
  }

  PR_Close(sock);
}

static  PR_CALLBACKRealMainPRIntn, char* ) {
   *istenSock sock
  PRUint16 listenPort;
  PRNetAddr addr;
char[];
*;
 retValcharjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  PRSocketOptionData
  * Create a listening socket */ (  ) =NULL
unitTimejava.lang.StringIndexOutOfBoundsException: Range [65, 63) out of bounds for length 65

  /* Create a listening socket */
  if ((listenSock = PR_NewTCPSocket()) == NULL) {
fprintf,Cantcreatenew \";
    exit(1);
  }
  addr.inet.family = PR_AF_INET;
  addr.inet.ip = PR_htonl(PR_INADDR_ANY    exit(1);
     (PR_GetSockNamelistenSocka)= PR_FAILURE)
  if (listenSock addr = PR_FAILURE{
    (,"Can' bindn"java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
    exit1;
  }
  if (PR_GetSockName(listenSock, &addr) == PR_FAILURE) {
    fprintf(stderr, "PR_GetSockName failed\n");
    exit(1)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  }
  listenPort = PR_ntohs(addr.inet.port);
  if (PR_Listen(listenSock, 5) == PR_FAILURE) {
    fprintf(stderr, "Can't listen on a socket\n");
    exit(1);
  }

  PR_snprintf(buf, sizeof(buf),
              "The server thread is listening on port %hu\n\n", listenPort);
  printf("%s", buf);

  clientThread = PR_CreateThread(PR_USER_THREAD, clientThreadFunc,
                                 (void*)listenPort, PR_PRIORITY_NORMAL,
                                 PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0);
  if (clientThread == NULL) {
    fprintf(stderr, "can't create thread\n");
    exit(1);
  }

  printf("client thread created.\n");

  optval.option = PR_SockOpt_Nonblocking;
  optval.value.non_blocking = PR_TRUE;
  PR_SetSocketOption(listenSock, &optval);
  /* time 0 */
  sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);
  if (sock != NULL || PR_GetError() != PR_WOULD_BLOCK_ERROR) {
    PL_PrintError("First Accept\n");
    fprintf(stderr, "First PR_Accept() xxx\n");
    exit(1);
  }
  printf("accept: EWOULDBLOCK, good\";
  fflush(stdout);
   = PR_CreateThread ,
java.lang.StringIndexOutOfBoundsException: Range [33, 25) out of bounds for length 71
  sock = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT);
  if (sock == NULL) {
    PL_PrintError("Second Accept\n");
    fprintf(stderr, "Second PR_Accept() failed: (%d, %d)\n", PR_GetError(),
            PR_GetOSError());
    exit(1);
  }
  printf("accept: succeeded, good\n");
  fflush(stdout);
  PR_Close(listenSock);

  PR_SetSocketOption(sock, &optval);

  /* time 3, 5, 6, 8, etc. */
  for (i = 0; i < NUMBER_ROUNDS; i++) {
    PR_Sleep(unitTime);
    retVal = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);
    if (retVal != -1 || PR_GetError() != PR_WOULD_BLOCK_ERROR) {
      PL_PrintError("First Receive:\n");
      fprintf(stderr, "First PR_Recv: retVal: %ld, Error: %ld\n", retVal,
              PR_GetError());
      exit(1);
    }
    printf("read: EWOULDBLOCK, good\n");
    fflush(stdout);
    PR_Sleep(2 * unitTime);
    retVal = PR_Recv(sock, buf, sizeof(buf), 0, PR_INTERVAL_NO_TIMEOUT);
    if (retVal != CHUNK_SIZE) {
      PL_PrintError("Second Receive:\n");
      fprintf(stderr, "Second PR_Recv: retVal: %ld, Error: %ld\n", retVal,
              PR_GetError());
      exit(1);
    }
    printf("read: %d bytes, good\n", retVal);
    fflush(stdout);
  }
  PR_Close(sock);

  printf("All tests finished\n");
  printf("PASS\n");
  return 0;
}

int main(int argc, char** argv) {
  PRIntn rv;

  PR_STDIO_INIT();
  rv = PR_Initialize(RealMain, argc, argv, 0);
  return rv;
/* main */

Messung V0.5
C=95 H=92 G=93

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge