// eeeee.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <conio.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
	
	HANDLE PipeHandle;
	DWORD BytesRead;
	DWORD BytesWritten;
	CHAR buffer[256];
	CHAR otvet[256];
	DWORD Ret;
	if ((PipeHandle=CreateNamedPipe("\\\\.\\pipe\\sdf",PIPE_ACCESS_DUPLEX,PIPE_TYPE_BYTE,1,256,256,1000,NULL))==INVALID_HANDLE_VALUE)
	{
		printf ("Create...Error%d\n", GetLastError());
		return 0;
	}
	printf("Server is NOW running\n");
	if (ConnectNamedPipe(PipeHandle, NULL)==0)
	{
		printf("Connect///error%d\n",GetLastError());
		CloseHandle(PipeHandle);
		return 0;
	}
	if(Ret= ReadFile(PipeHandle,buffer,sizeof(buffer), &BytesRead, NULL)<=0)
	{
		printf("Read error%d\n",GetLastError());
		printf("%i\n",Ret);
		CloseHandle(PipeHandle); 
		return 0;
	}
	buffer[BytesRead]='\0';
	printf ("%.*s\n",BytesRead, buffer);
	gets(otvet);
	if(WriteFile(PipeHandle, otvet, strlen(otvet),&BytesWritten,NULL)==0)
	{
		printf ("write///error%d\n", GetLastError());
		CloseHandle(PipeHandle);
		return 0;
	}

		while(ReadFile(MS, buffer, 256, &NumberOfBytesRead,
		NULL)!=0)
	return 0;
}
