68 Ethernet module User’s Manual
Chapter 5 Computer Link Protocol and the PC Link Protocol Transmission
5
/*---------------------------------*/
/* Prototype declarations   */
/*---------------------------------*/
int   cl_send( int ); /* Register read/write processing */
void main()
{
    int   ists; /* Return status */
    int   isdp ; /* Socket identifier */
    int   i    ; /* Loop counter */
    struct  sockaddr_in   Soc;
    WORD  wVersionRequested = (0,1); /* WINSOC version number specification */
    WSADATA  WsaDtata ; /* WINSOC data structure */
/* Initialization */
 ists = 0 ; /* Initial value setting */
/* Windows socket initialization */
   ists = WSAStartup( wVersionRequested, &WsaDtata ) ;
 if( ists == 0 ){ /* If normal return: */
    isdp = socket(AF_INET, SOCK_DGRAM, 0); /* Create socket (UDP) */
    if( isdp != INVALID_SOCKET ){ /* If normal return: */
  Soc.sin_family = AF_INET;
  Soc.sin_addr.s_addr = 0 ; /* Set local IP address */
  Soc.sin_port = htons( MY_PORT ); /* Set local port number */
/* Execute bind processing */
  ists = bind(isdp, (struct sockaddr *)&Soc, sizeof(Soc) );
  if( ists != SOCKET_ERROR ){ /* If bind completed normally: */
     for( i = 0; i < LOOP; i++){ /* Loop for the specified number of times */
        ists = cl_send( isdp ); /* Register read/write processing */
        if( ists != 0 ) /* If an error occurred in register
    read/write processing */
     break ; /* Terminate processing */
     }
  }
  closesocket( isdp ) ;  /* Socket close processing */
    }
 }
 WSACleanup() ; /* Report WINSOC termination */
    }