By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,221 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,221 IT Pros & Developers. It's quick & easy.

Socket Poll returns writable but not readable

P: n/a
I have created a static class-level socket for use by the class member
functions:

static Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

The Connect and Disconnect methods work fine, as does the synchronous Send
method. However, the Poll method returns true for SelectMode.SelectWrite
and false for SelectMode.SelectRead. Therefore, synchronous Read won't
return anything.

Based on this information, can anyone explain why this new socket would be
writable but not readable?

Thanks for any information.

Aug 15 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
JDavis <da***@spamfree.comwrote:
I have created a static class-level socket for use by the class member
functions:

static Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

The Connect and Disconnect methods work fine, as does the synchronous Send
method. However, the Poll method returns true for SelectMode.SelectWrite
and false for SelectMode.SelectRead. Therefore, synchronous Read won't
return anything.

Based on this information, can anyone explain why this new socket would be
writable but not readable?

Thanks for any information.
Is this because there's no data available yet, so a Receive call would
block? What happens if you put data in there?

Out of interest, do you have a reason for polling instead of using the
asynchronous calls?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 15 '07 #2

P: n/a
Is this because there's no data available yet, so a Receive call would
block? What happens if you put data in there?
I have no control over the server end, so I can't simulate this (it's run by
a B2B business partner, and made available to clients "as is"). However, I
suspect that you are right and I am now writing a timer to check every 5
seconds.
Out of interest, do you have a reason for polling instead of using the
asynchronous calls?
I'm new to sockets programming and the synchronous methods are easier to
implement (although more primitive). As I have no control over the server,
I need a quick method to see if I can establish communication and receive
data. Once that's accomplished, I will implement asynch methods.

BTW, this will establish continuous streams. I wonder if asynchronous
methods are appropriate for that. I am translating from a set of C++
programs, wherein the client polls once a second. Any thoughts?
"JDavis" <da***@spamfree.comwrote in message
news:wu******************************@giganews.com ...
>I have created a static class-level socket for use by the class member
functions:

static Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

The Connect and Disconnect methods work fine, as does the synchronous Send
method. However, the Poll method returns true for SelectMode.SelectWrite
and false for SelectMode.SelectRead. Therefore, synchronous Read won't
return anything.

Based on this information, can anyone explain why this new socket would be
writable but not readable?

Thanks for any information.

Aug 15 '07 #3

P: n/a
Hi,

"JDavis" <da***@spamfree.comwrote in message
news:wu******************************@giganews.com ...
>I have created a static class-level socket for use by the class member
functions:
If it's static it's not only shared by members of the same instance but ALL
the instances of the type will use the same. Are you this is the required
feature?

Aug 15 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.