• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:26
CEST 16:26
KST 23:26
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29LiuLi Cup - September 2025 Tournaments3
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Maestros of The Game—$20k event w/ live finals in Paris SC4ALL $6,000 Open LAN in Philadelphia WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
ASL20 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Pros React To: SoulKey's 5-Peat Challenge [ASL20] Ro16 Preview Pt2: Turbulence BW General Discussion
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile General RTS Discussion Thread Nintendo Switch Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine UK Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1238 users

[H] Named Pipes part 2

Blogs > Phyre
Post a Reply
Phyre
Profile Blog Joined December 2006
United States1288 Posts
November 15 2009 15:47 GMT
#1
Hi guys, thanks for the advice. Sorry it took so long to respond, I don't have much time to work on this during the week. Continuing from my last blog post, I think I've made a little headway.

I've been trying to get a C++ client to send a message to a C# server and I'm having difficulty on the C++ client side. I'm using the sample C++ client shown here with no changes at all, 100% copy/pasted right now. The problem seems to be in the line where I'm trying to set the Read Mode with SetNamedPipeHandleState() to PIPE_READMODE_MESSAGE. When I have the client try to connect to the server it stops and prints "SetNamedPipeHandleState failed. GLE=87".

I heard that setting the read mode to Message can fail if the pipe is set to Byte mode on the server end but pipes are set to Message mode by default in C# anyway. I manually set the read mode of the C# server anyway with "pipeServer.ReadMode = PipeTransmissionMode.Message;" just incase and that caused the server to crash when the client attempted to connect.

The closest I've gotten to making this work is setting the Readmode on the C++ client end to Byte with "dwMode = PIPE_READMODE_BYTE;" which allows the client to successfully send a message to the server, albeit a bit messed up. The text I send in Byte mode has spaces between every letter which is obviously not what I want.

The server code I'm using is this:

using System;
using System.IO;
using System.IO.Pipes;

class PipeServer
{
static void Main()
{
ListenServer();
}

static void ListenServer()
{
bool keepRunning = true;

while (keepRunning)
{
using (NamedPipeServerStream pipeServer =
new NamedPipeServerStream("testpipe", PipeDirection.InOut))
{
//Console.WriteLine("NamedPipeServerStream object created.");

// Wait for a client to connect
Console.WriteLine("Pipe Server");
Console.WriteLine("Waiting for client connection...");
pipeServer.WaitForConnection();
//pipeServer.ReadMode = PipeTransmissionMode.Message;

Console.WriteLine("Client connected.");
try
{
using (StreamReader sr = new StreamReader(pipeServer))
{
// Display the read text to the console
string temp;
while ((temp = sr.ReadLine()) != null)
{
Console.WriteLine("Received from client: {0}", temp);
}
}
}
// Catch the IOException that is raised if the pipe is
// broken or disconnected.
catch (IOException e)
{
Console.WriteLine("ERROR: {0}", e.Message);
}
}
}
}
}


Thanks for reading if you've made it this far, the help is very much appreciated!

"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
Phyre
Profile Blog Joined December 2006
United States1288 Posts
November 15 2009 19:11 GMT
#2
Turns out I was setting the Readmode on the C# server end of things at the wrong time. I moved it to be before the WaitForConnection call and it works now. Says everywhere I've read that C# pipes are supposed to default to Message mode to begin with but they apparently don't. So, that's fixed but the text is still being sent to the server with a blank space between every character which is confusing me. I'll keep looking.
"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
Phyre
Profile Blog Joined December 2006
United States1288 Posts
November 15 2009 20:47 GMT
#3
And finally, a friend of mine helped solved the last piece of this puzzle. Just had to change the output of the C++ client to "Not Set" aka ASCII in the project properties instead of Unicode.

Now to make the C++ client a service and the C# server a GUI app. Can't be that bad...
"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
Please log in or register to reply.
Live Events Refresh
Next event in 4h 34m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Vindicta 74
ProTech71
Creator 20
StarCraft: Brood War
Britney 49689
Bisu 3291
Rain 2392
Horang2 1839
GuemChi 1694
Hyuk 1303
EffOrt 966
firebathero 640
Mini 477
BeSt 448
[ Show more ]
Larva 428
Killer 385
Zeus 250
ZerO 208
Snow 192
Soma 165
Hyun 123
hero 102
Rush 77
Sharp 59
sorry 53
soO 48
ToSsGirL 48
Backho 46
JYJ41
sas.Sziky 26
Free 21
Sacsri 20
scan(afreeca) 18
Sexy 16
Bale 16
Terrorterran 15
ajuk12(nOOB) 14
Noble 10
NaDa 10
Hm[arnc] 7
Rock 5
Dota 2
Gorgc5346
singsing3848
qojqva2987
Dendi1500
420jenkins325
XcaliburYe296
Fuzer 240
Counter-Strike
zeus631
oskar132
kRYSTAL_0
Other Games
gofns30372
tarik_tv19943
B2W.Neo1000
RotterdaM566
hiko531
DeMusliM517
crisheroes378
Hui .361
XaKoH 145
Liquid`VortiX112
Sick91
TKL 88
QueenE70
NeuroSwarm41
Trikslyr28
ZerO(Twitch)14
Organizations
StarCraft: Brood War
UltimateBattle 1454
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3000
• WagamamaTV321
League of Legends
• Nemesis7493
• Jankos1557
• TFBlade475
Other Games
• Shiphtur87
Upcoming Events
OSC
4h 34m
Cure vs Iba
MaxPax vs Lemon
Gerald vs ArT
Solar vs goblin
Nicoract vs TBD
Spirit vs Percival
Cham vs TBD
ByuN vs Jumy
RSL Revival
19h 34m
Maru vs Reynor
Cure vs TriGGeR
Map Test Tournament
20h 34m
The PondCast
22h 34m
RSL Revival
1d 19h
Zoun vs Classic
Korean StarCraft League
2 days
BSL Open LAN 2025 - War…
2 days
RSL Revival
2 days
BSL Open LAN 2025 - War…
3 days
RSL Revival
3 days
[ Show More ]
Online Event
4 days
Wardi Open
4 days
Monday Night Weeklies
5 days
Sparkling Tuna Cup
5 days
LiuLi Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.