• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:30
CEST 15:30
KST 22:30
  • 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
[ASL19] Finals Recap: Standing Tall10HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Firefly given lifetime ban by ESIC following match-fixing investigation5$25,000 Streamerzone StarCraft Pro Series announced4Weekly Cups (June 30 - July 6): Classic Doubles6[BSL20] Non-Korean Championship 4x BSL + 4x China9Flash Announces Hiatus From ASL66
StarCraft 2
General
TL Team Map Contest #4: Winners Weekly Cups (June 30 - July 6): Classic Doubles The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings Firefly given lifetime ban by ESIC following match-fixing investigation
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event $25,000 Streamerzone StarCraft Pro Series announced Sparkling Tuna Cup - Weekly Open Tournament RSL: Revival, a new crowdfunded tournament series WardiTV Mondays
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ i aint gon lie to u bruh... ASL20 Preliminary Maps [G] Progamer Settings [ASL19] Finals Recap: Standing Tall
Tourneys
[BSL20] Non-Korean Championship 4x BSL + 4x China [BSL20] Grand Finals - Sunday 20:00 CET CSL Xiamen International Invitational The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Positive Thoughts on Setting Up a Dual-Caliber FX
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 Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread Summer Games Done Quick 2025! Stop Killing Games - European Citizens Initiative
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
momentary artworks from des…
tankgirl
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 629 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 2h 30m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ForJumy 90
StarCraft: Brood War
Shuttle 2677
Flash 2295
Bisu 1649
firebathero 1373
EffOrt 955
actioN 548
Mini 535
Larva 529
Hyuk 382
Soulkey 333
[ Show more ]
Snow 327
Last 209
hero 202
Soma 199
Zeus 176
ToSsGirL 129
TY 121
soO 114
Hyun 100
Pusan 63
sorry 62
JYJ38
Rush 35
Noble 32
JulyZerg 26
Yoon 25
Sacsri 23
GoRush 21
yabsab 17
HiyA 12
Movie 12
IntoTheRainbow 8
Icarus 7
Terrorterran 6
zelot 5
ivOry 2
GuemChi 0
Dota 2
Gorgc10164
qojqva2002
XcaliburYe231
League of Legends
singsing2243
Counter-Strike
x6flipin384
allub221
byalli199
chrisJcsgo119
flusha70
Heroes of the Storm
Khaldor104
Other Games
tarik_tv24027
gofns13740
B2W.Neo1191
FrodaN862
shahzam539
DeMusliM520
hiko517
Fuzer 246
crisheroes195
QueenE36
Organizations
Other Games
gamesdonequick36404
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• HeavenSC 17
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 13
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis4028
Upcoming Events
uThermal 2v2 Circuit
2h 30m
WardiTV European League
2h 30m
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
Replay Cast
10h 30m
RSL Revival
20h 30m
ByuN vs SHIN
Clem vs Reynor
OSC
23h 30m
Replay Cast
1d 10h
RSL Revival
1d 20h
Classic vs Cure
FEL
2 days
OSC
2 days
RSL Revival
2 days
[ Show More ]
FEL
2 days
FEL
3 days
CSO Cup
3 days
BSL20 Non-Korean Champi…
3 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
3 days
RSL Revival
3 days
FEL
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Replay Cast
5 days
Liquipedia Results

Completed

Proleague 2025-07-07
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
Underdog Cup #2
StarSeries Fall 2025
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
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.