-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.cs
30 lines (22 loc) · 865 Bytes
/
server.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.IO.Pipes;
using System.Text;
namespace NamedPipesPython {
class Program {
static void Main(string[] args) {
NamedPipeServerStream server = new NamedPipeServerStream("Server", PipeDirection.InOut, 1, PipeTransmissionMode.Message);
server.WaitForConnection();
byte[] bytes_to_write = Encoding.ASCII.GetBytes("Hello Python");
server.Write(bytes_to_write, 0, bytes_to_write.Length);
byte[] bytes_to_read = new byte[1];
string message = "";
do {
server.Read(bytes_to_read, 0, 1);
message += Encoding.UTF8.GetString(bytes_to_read);
} while (!server.IsMessageComplete);
Console.Write(message);
server.Disconnect();
server.Close();
}
}
}