Socket Poll returns writable but not readable

  • Thread starter Thread starter JDavis
  • Start date Start date
J

JDavis

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.
 
JDavis said:
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?
 
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?
 
Hi,

JDavis said:
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?
 
Back
Top