473,472 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Socket Poll returns writable but not readable

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
3 3083
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe Wong | last post by:
Hello, I have a short program that the client make a connection to server, a thread is then created to poll any data sent from the server. The main thread will close the socket after 5 seconds....
1
by: Tim Gosselin | last post by:
I am writing a tcp tunnel but cannot find a way of detecting when a socket shuts down its read end without writing to the socket. For testing the write end of the remote endpoint I just do a: if...
1
by: ETYC | last post by:
I am not sure if this is a bug or not but it seems strange to me. If I set the tcp socket blocking to false and do a connect, then I can catch the socketexception. If the exception is...
4
by: Frank Meng | last post by:
Hi. I am trying a csharp sample from http://www.codeproject.com/csharp/socketsincs.asp . (Sorry I didn't post all the source codes here, please get the codes from above link if you want to try)....
0
by: et-yc | last post by:
I am not sure if this is a bug or not but it seems strange to me. If I set the tcp socket blocking to false and do a connect, then I can catch the socketexception. If the exception is...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
6
by: billiejoex | last post by:
Hi there. I'm setting up test suite for a project of mine. situations, if the socket is closed on the other end or not. I noticed that I can "detect" such state if a call to socket.read() returns...
21
by: puzzlecracker | last post by:
Problem: I send a lot of requests to the application (running on a different box, of course), and I receive back responses from the app . Below: socket corresponds to Socket socket=new...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.