/**
*
* @File : exo_01s.cxx
*
* @Authors : D. Mathieu
* M. Laporte
*
* @Date : 19/12/2000
*
* @Version : V1.0
*
* @Synopsis :
*
**/
#include <iostream>
#include <string>
#include <exception>
#include <unistd.h> // sleep()
#include <netinet/in.h> // htons(), ntohs()
#include <sys/socket.h> // MSG_OOB
#include "CExc.h"
#include "nsSysteme.h"
#include "nsNet.h"
using namespace nsSysteme;
using namespace nsNet;
int std::ppal (int argc, char * argv []) throw (exception)
{
if (1 != argc)
throw nsBAO::CExc (string ("Usage : ") + argv [0]);
unsigned short NumPort = Getportbyname ("mathieu", "tcp");
const int sd = ServeurSockInStream (NumPort);
cout << "Port = " << ::ntohs (NumPort) << endl;
const char Urgent [] = "Urgent";
const char NonUrgent [] = "Non Urgent";
const int sdComm = ServeurAccept (sd);
for (;;)
{
Send (sdComm, NonUrgent, ::strlen (NonUrgent));
sleep(1);
// Attention : un message urgent est constitué d'un seul caractère
Send (sdComm, Urgent, 1, MSG_OOB);
sleep(1);
}
Close (sdComm);
Close (sd);
return 0;
} // ppal()