This post has moved to http://peted.azurewebsites.net/streamsocket-example-c-metro/
Thank you! I was having trouble reading input from a StreamSocket until I saw how you were using InputStreamOptions.Partial. My problem was that I was trying to read a smaller input with too large of a buffer, so it was hanging indefinitely.
I’ve been having trouble with a project i’m working on. It throws a datareader/datawriter error saying “the object is closed.”. I downloaded your project and ran it and am receiving the same error. Do you know anything about this? Any suggestions?
To duplicate it, try listening, connecting, send 1 message, reply 1 message, send another message…
This may be misunderstanding StreamSockets, but this is all well and good – and I have your sample running, however the chat client and server are within the one application? Wouldn’t I need to host the ‘server’ component on a server somewhere on a windows service or something?
I try to implement the server code on any other project type, WPF, console app etc. and I can’t find Windows.Networking namespace.
Now I’m really confused, I wouldn’t want the server to be another Windows Store app?
Hope you can shed some light on this!
Yes, I could well have separated the code into distinct server and client parts. I just wanted to show both parts of the code from a winrt perspective and having each endpoint act as both seemed simpler to me. In general if you want to code either client or server in a different technology then you would need to use the stack which is available in that environment. In this case though you can use WinRT apis from .NET desktop applications. I have an example in my latest post which shows a WPF socket server working with a a metro client see http://babaandthepigman.wordpress.com/2012/10/12/metro-app-and-kinect-voice-control/
Ah, awesome. That makes sense, thanks. I’ve also since been looking at trying to use it with the Microsoft.WebSockets NuGet package too. Will take a look at your WPF client, thanks.
Is it necessary to send/recv the size of the message? I’m trying to get the listener to work with a telnet client and its giving a bit of trouble.
It’s not necessary to send the size of the message – this is just a way of ‘framing’ the data (you need some way to determine the beginning/end of a message)
I’m trying to make a simple test server using StreamSocketListener that I can telnet to. For some reason the telnet client cannot connect to it. Netstat shows there is a tcp connection listening on the port I chose. Any idea? Have you by chance used the listener and connected a telnet client to it? I’ve done this before using .net tcplistener w/o issue.
I separated the code into client/server but i could not get it to work.
When i was trying to connect from client to my already running server i was getting an error(due to time out i suspect my server was unreachable) .I tried localhost and ip and different ports but i had no luck any ideas on what i may be missing?
++I think your facebook link does not work although i connected through i was unable to post a comment++
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.
Get every new post delivered to your Inbox.