[Server - C#]
using System;
using System.IO;
using System.IO.Pipes;
namespace NamedPipeCs
{
class Program
{
static void Main(string[] args)
{
while (true)
{
using (var server = new NamedPipeServerStream("DavidPipe"))
{
server.WaitForConnection();
using (var reader = new StreamReader(server))
{
string temp;
while ((temp = reader.ReadLine()) != null)
{
Console.WriteLine("{0}", temp);
}
}
}
}
}
}
}
----------------------------------------------------------------------------
[Client - C++]
#include <iostream>
using namespace std;
#include <windows.h>
int main()
{
HANDLE hPipe = CreateFile("\\\\.\\pipe\\DavidPipe", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hPipe == NULL || hPipe == INVALID_HANDLE_VALUE)
return -1;
LPTSTR lpMessage = TEXT("FUCK THAT SHIT");
DWORD dwNumberOfBytesToWrite = (lstrlen(lpMessage) + 1) * sizeof(TCHAR);
DWORD dwNumberOfBytesWritten;
BOOL bSuccess = WriteFile(hPipe, lpMessage, dwNumberOfBytesToWrite, &dwNumberOfBytesWritten, NULL);
if (bSuccess == FALSE)
return -1;
CloseHandle(hPipe);
return 0;
}
'Programming > Etc' 카테고리의 다른 글
Singleton Pattern (0) | 2015.11.02 |
---|---|
순열(Permutation)과 조합(Combination) (0) | 2015.10.26 |
게임 개발 성과 측정 프로젝트 마지막편: 위대한 팀은 어떻게 일하는가? (0) | 2015.04.15 |
What is a tight loop? (0) | 2015.02.27 |
HTML5 vs PhoneGap vs Unity3D vs Native (0) | 2015.02.14 |