• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:59
CEST 00:59
KST 07:59
  • 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
Code S RO8 Preview: Rogue, GuMiho, Solar, Maru2BGE Stara Zagora 2025: Info & Preview27Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL47Code S RO12 Preview: Cure, Zoun, Solar, Creator4
Community News
BGE Stara Zagora 2025 - Replay Pack1Weekly Cups (June 2-8): herO doubles down1[BSL20] ProLeague: Bracket Stage & Dates9GSL Ro4 and Finals moved to Sunday June 15th13Weekly Cups (May 27-June 1): ByuN goes back-to-back0
StarCraft 2
General
BGE Stara Zagora 2025 - Replay Pack Code S RO8 Preview: Rogue, GuMiho, Solar, Maru Jim claims he and Firefly were involved in match-fixing The SCII GOAT: A statistical Evaluation StarCraft 1 & 2 Added to Xbox Game Pass
Tourneys
[GSL 2025] Code S:Season 2 - RO8 - Group A Sea Duckling Open (Global, Bronze-Diamond) Bellum Gens Elite: Stara Zagora 2025 $3,500 WardiTV European League 2025 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[G] Darkgrid Layout Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 477 Slow and Steady Mutation # 476 Charnel House Mutation # 475 Hard Target Mutation # 474 Futile Resistance
Brood War
General
BW General Discussion BGH auto balance -> http://bghmmr.eu/ FlaSh Witnesses SCV Pull Off the Impossible vs Shu StarCraft & BroodWar Campaign Speedrun Quest Will foreigners ever be able to challenge Koreans?
Tourneys
RECOVER LOST BTC USDT FUNDS RECLAIMER COMPANY [ASL19] Grand Finals [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET NA Team League 6/8/2025
Strategy
I am doing this better than progamers do. [G] How to get started on ladder as a new Z player
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread What do you want from future RTS games? Armies of Exigo - YesYes? Nintendo Switch Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
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
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread Vape Nation Thread European Politico-economics QA Mega-thread
Fan Clubs
Maru Fan Club Serral Fan Club
Media & Entertainment
Korean Music Discussion [Manga] One Piece
Sports
2024 - 2025 Football Thread Formula 1 Discussion NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
A Better Routine For Progame…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 25923 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
BSL: GosuLeague
19:15
Quarter Finals
Hejek vs Herbmon
Semih vs Kyrie
cavapoo vs TousaN
ZZZero.O115
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
UpATreeSC 156
PiGStarcraft120
JuggernautJason76
CosmosSc2 37
EnDerr 31
StarCraft: Brood War
Britney 17131
Sea 1246
Artosis 605
ZZZero.O 115
Dota 2
PGG 169
League of Legends
tarik_tv10234
Counter-Strike
fl0m4907
Super Smash Bros
PPMD99
Heroes of the Storm
Grubby3212
Khaldor102
Other Games
summit1g7152
shahzam975
ViBE122
Maynarde76
Organizations
Dota 2
PGL Dota 2 - Main Stream4473
Other Games
gamesdonequick190
BasetradeTV165
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• RyuSc2 55
• davetesta40
• Berry_CruncH28
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• Diggity2
• HerbMon 2
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22191
League of Legends
• Shiphtur774
Other Games
• imaqtpie935
• Scarra784
Upcoming Events
PiGosaur Monday
1h 1m
PiGStarcraft120
GSL Code S
10h 31m
Rogue vs GuMiho
Maru vs Solar
Online Event
1d 1h
Replay Cast
1d 3h
GSL Code S
1d 10h
herO vs Zoun
Classic vs Bunny
The PondCast
1d 11h
Replay Cast
2 days
WardiTV Invitational
2 days
OSC
2 days
Korean StarCraft League
3 days
[ Show More ]
SOOP
3 days
CranKy Ducklings
3 days
WardiTV Invitational
3 days
Cheesadelphia
3 days
CSO Cup
3 days
GSL Code S
4 days
Sparkling Tuna Cup
4 days
Replay Cast
5 days
Wardi Open
5 days
Replay Cast
6 days
Replay Cast
6 days
RSL Revival
6 days
Cure vs Percival
ByuN vs Spirit
Liquipedia Results

Completed

CSL Season 17: Qualifier 2
BGE Stara Zagora 2025
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL 17: 2025 SUMMER
2025 GSL S2
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
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Murky Cup #2
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.