Hi all,
I have coded an outbound Socket program in C on a solaris box that
sends out data and receives an acknowledgement for it.
However, have faced this problem of a "HANG" state, whereby the read()
function does not return any values.
===========code attached=============================
int readn(int fd, char *ptr)
{
int ntot, nread, found, sr; //sr added 11th May
char *start_posn, *end_posn;
start_posn = ptr;
found = 0;
ntot = 0;
nread = read(fd, ptr, 1); <===read does not return. "HANG STATE"
if (nread < 0)
{
if (found)
return -43;
else
return -42;
}
else if (nread == 0)
{
log(nread,"break from loop","",read_ini_file());
break;
}
================================================== ==========
The required action was to stop and restart the socket.
Have tried to intercept this with a select() (to check on the socket)
However, with a select() 2sec is to be set for the timeval.
This will greatly cripple the performance and thus causing us to be
reluctant in adding this code.
Would be good if someone is able to explain why read() does not return
a vaule when there is no data to be read on the socket.
Thanks! 2 3612
zb011 message <sp******@yahoo.com> scribbled the following: Hi all,
I have coded an outbound Socket program in C on a solaris box that sends out data and receives an acknowledgement for it.
ISO standard C does not define sockets. Please ask in
comp.unix.programmer.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
zb011 message wrote: I have coded an outbound Socket program in C on a solaris box that sends out data and receives an acknowledgement for it.
However, have faced this problem of a "HANG" state, whereby the read() function does not return any values. ===========code attached============================= int readn(int fd, char *ptr) { int ntot, nread, found, sr; //sr added 11th May char *start_posn, *end_posn; start_posn = ptr; found = 0; ntot = 0;
nread = read(fd, ptr, 1); <===read does not return. "HANG STATE"
There is no such function as 'read' in ISO C. Either use fread or
supply the code for the read function, or ask in a newsgroup
dedicated to your system.
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Robert A. van Ginkel |
last post by:
In news:OZ0W9RsdDHA.2432@TK2MSFTNGP10.phx.gbl... I ask the question how I
can see if all the data is on the other side of the connection.
I got as answer that I should use the blocking property.
I...
|
by: John Sheppard |
last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand.
Programming environment. VS.NET 2003, C#, Windows...
|
by: Macca |
last post by:
Hi,
I have a synchronous socket server which my app uses to read data from
clients.
To test this I have a simulated client that sends 100 byte packets.
I have set up the socket server so...
|
by: Abubakar |
last post by:
Hi,
lets say I have a connected SOCKET s. At some point in time, I want to know
if the "s" is still valid, that it is still connected. Is there any API that
I can give me this information?
And...
|
by: djc |
last post by:
I read a network programming book (based on framework 1.1) which indicated
that you should 'never' use the RecieveTimeout or the SendTimeout 'socket
options' on TCP sockets or you may loose data. I...
|
by: Engineerik |
last post by:
I am trying to create a socket server which will listen for connections from
multiple clients and call subroutines in a Fortran DLL and pass the results
back to the client. The asynchronous socket...
|
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)
{...
|
by: John Salerno |
last post by:
I wrote some pretty basic socket programming again, but I'm still confused about what's happening with the buffer_size variable. Here are the server and client programs:
--------------
from...
|
by: TheGTA |
last post by:
Hi there!
I am working on a project for like 1 year now.
Most of it works well.
But somehow my socketenvironment craps out sometimes...
For a totally unknown reason a socket crashes with...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
| |