473,378 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Socket.Available != 0 but Socket.Read throws an exception

Hello Everybody,

I have the following problem with Socket:
Socket.Available reports data in the buffer (e.g. 1849 bytes) but I can't
read it because Socket.Read throws an exception
The exception ist being thrown because the connection is already closed. How
could I read the data from the buffer?

background information:
I open multiple connections to my Windows 2003 Web Server (simple HTTP GET).

pseudocode:
while (true) {
foreach open socket {
if should read
read
if should write
write
}

if new connection needed
create new connection
}

The IIS sends the data and closes the connection imediatelly. Sometimes my
application is not ready to "read" because it's doing something else at the
moment.
Shouldn't I be able to access the buffer even if the connection is closed by
the server?

Thanks!
tomek


Nov 16 '05 #1
0 2053

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
5
by: Terry | last post by:
It's my understanding of UDP sockets that if there is a thread blocked on a "recvFrom()" call and other thread sends a UDP packet to some address, that if the machine on the other end isn't up,...
2
by: Dilip | last post by:
Gurus I didn't personally encounter these problems but some friends of mine who are doing some deep heavy-metal C#/Networking application have run into these problems. Does anybody have any...
0
by: Tomasz Naumowicz | last post by:
Hello Everybody, I have the following problem with sockets. Socket.Available reports data in the buffer (e.g. 1849 bytes) but Socket.Read throws an exception because the connection is already...
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...
2
by: Nuno Magalhaes | last post by:
I've got a simple problem I guess. How do I know when a connection is terminated without losing any data? I do something like the code below, but sometimes between socket.Receive and socket.Send...
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
4
by: Andrew Jackson | last post by:
I am writing a newsgroup client. I have the protocol figured out. But I get slow transfer speeds off any of the network objects read the data from For example one of the commands for a news...
0
by: rcarmich | last post by:
I am having an issue canceling a beginReceive call on a timeout. For example, the following function: public int ReadBytes(Socket theSock, byte arr, int startByte, int length, int timeout) {...
3
by: TsanChung | last post by:
I want to make a java TCP socket client to communicate with a TCP server socket on linux. Are there some sample C unix server and java client socket programs available? The Richard Stevens'...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.