I have created a static class-level socket for use by the class member
functions:
static Socket s = new Socket(AddressF amily.InterNetw ork, SocketType.Stre am,
ProtocolType.Tc p);
The Connect and Disconnect methods work fine, as does the synchronous Send
method. However, the Poll method returns true for SelectMode.Sele ctWrite
and false for SelectMode.Sele ctRead. 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. 3 3107
JDavis <da***@spamfree .comwrote:
I have created a static class-level socket for use by the class member
functions:
static Socket s = new Socket(AddressF amily.InterNetw ork, SocketType.Stre am,
ProtocolType.Tc p);
The Connect and Disconnect methods work fine, as does the synchronous Send
method. However, the Poll method returns true for SelectMode.Sele ctWrite
and false for SelectMode.Sele ctRead. 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.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
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******** *************** *******@giganew s.com...
>I have created a static class-level socket for use by the class member functions:
static Socket s = new Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p);
The Connect and Disconnect methods work fine, as does the synchronous Send
method. However, the Poll method returns true for SelectMode.Sele ctWrite
and false for SelectMode.Sele ctRead. 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.
Hi,
"JDavis" <da***@spamfree .comwrote in message
news:wu******** *************** *******@giganew s.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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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. Here are the code:
from socket import *
import select
import threading
import time
def poll(c):
|
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 not sock.recv(buffsize)
I cannot write to the socket and check if send returns 0 though, because
that involves sending data out of the which may not have come in yet.
When I try polling the socket with:
|
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 WSAEWOULDBLOCK, then I do a poll with
timeout to see if I can connect to the remote host. When the poll returns
true, the socket Connected property is still false. Why is this?
sock.Blocking = false;
try
{
sock.connect (...)
|
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).
I had some troubles when I started 6 threads (each thread made a
separate connection) and sent messages to same server simultaneously.
Sometimes, not always, the socket looks like ok, but really it is
dead.
I don't why it happens.
|
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 WSAEWOULDBLOCK, then I do a poll with
timeout to see if I can connect to the remote host. When the poll returns
true, the socket Connected property is still false. Why is this?
sock.Blocking = false;
try
{
sock.connect (...)
| |
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
more data to expect). Sometimes, Socket.Available returns 0 but the other
end of the connection did not close it !
2) This class will be used by many other classes so I have to use the
|
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 write an helper method that will tell if the socket is connected or not , but it's not working good
continue to tell me that the socket is connectedeven if the other party already call shutdown(both) + close , or , even if the other party close the...
|
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 0 but it seems a little poor to me. :-\
Is there a reliable way to test such socket 'state'?
|
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
Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |