HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- HPUX & C socket programming problem
Operating System - HP-UX
1827243
Members
2319
Online
109716
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2001 12:59 AM
08-07-2001 12:59 AM
HPUX & C socket programming problem
We have 2 socket applications running on 2 different machines.
1. The socket server is running on HP-UX. (Version 11.0)
2. The socket client is running on SCO-UNIX (Open Server 5.0)
The scenario is as follows:
1. The client will send a request message (540 characters) to the socket server and waits for the response from the server.
2. The server will reply with a response message (540 characters) using the write( ) function.
We simulate a link failure scenario by unplugging the network cable of the client machine from the network
after the client has sent the request message to the server and before the server can
reply with a response message using the C write( ) function.
We notice the following:
1. The C write( ) function returns successfully.
QUESTION: Shouldn't the write( ) function return an error??
So we try out another method.
1. We, first,set the send buffer size to 540 (which is the size of our message) using the setsockopt function (sockfd, SOL_SOCKET, (char*)sendBufSize, 540) on the connected socket.
2. Followed by, we issue the select function on the socket to test whether it is write ready. If it is not write ready, we will assume there is a link failure. However, it always return write ready.
QUESTION: BUT how can it return write ready when the send buffer is not cleared (due to the link failure)
3. The segment for the server code is attached below for your reference.
4. The FD_ISSET always returns non zero.
n=write(sockfd, response, 540);
tv.tv_sec = 20;
tv.tv_usec = 0;
FD_ZERO(&wset);
FD_SET(sockfd, &wset);
returnVal=0;
returnVal=select(sockfd+1, NULL, &wset, NULL, &tv);
fprintf(logfd, "SExternal: after select() statement\n");
fflush(logfd);
if (returnVal >= 0) {
if (FD_ISSET(sockfd, &wset)) {
fprintf(logfd, "SExternal: write ready\n");
fflush(logfd);
} else {
fprintf(logfd, "SExternal: write not ready!!!\n");
fflush(logfd);
}
}
1. The socket server is running on HP-UX. (Version 11.0)
2. The socket client is running on SCO-UNIX (Open Server 5.0)
The scenario is as follows:
1. The client will send a request message (540 characters) to the socket server and waits for the response from the server.
2. The server will reply with a response message (540 characters) using the write( ) function.
We simulate a link failure scenario by unplugging the network cable of the client machine from the network
after the client has sent the request message to the server and before the server can
reply with a response message using the C write( ) function.
We notice the following:
1. The C write( ) function returns successfully.
QUESTION: Shouldn't the write( ) function return an error??
So we try out another method.
1. We, first,set the send buffer size to 540 (which is the size of our message) using the setsockopt function (sockfd, SOL_SOCKET, (char*)sendBufSize, 540) on the connected socket.
2. Followed by, we issue the select function on the socket to test whether it is write ready. If it is not write ready, we will assume there is a link failure. However, it always return write ready.
QUESTION: BUT how can it return write ready when the send buffer is not cleared (due to the link failure)
3. The segment for the server code is attached below for your reference.
4. The FD_ISSET always returns non zero.
n=write(sockfd, response, 540);
tv.tv_sec = 20;
tv.tv_usec = 0;
FD_ZERO(&wset);
FD_SET(sockfd, &wset);
returnVal=0;
returnVal=select(sockfd+1, NULL, &wset, NULL, &tv);
fprintf(logfd, "SExternal: after select() statement\n");
fflush(logfd);
if (returnVal >= 0) {
if (FD_ISSET(sockfd, &wset)) {
fprintf(logfd, "SExternal: write ready\n");
fflush(logfd);
} else {
fprintf(logfd, "SExternal: write not ready!!!\n");
fflush(logfd);
}
}
suranji
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2001 10:50 AM
08-07-2001 10:50 AM
Re: HPUX & C socket programming problem
no, the write() call should not return an error. write() completes when the data is successfully transfered to the _kernel_ there are no semantics to write() that mean the data made it to the remote system.
further, TCP detects failure after retransmission timeouts. that will take some period of time based on ndd settings. you do not necessarily want tcp to go belly-up if someone simply unplugs and reconnects a cable once and again, so even if there is a disconnect indication sent from the NIC, TCP (likely IP actually) would not necessarily say things were toast immediately. it might start tring to find another way to get the data there.
further, TCP detects failure after retransmission timeouts. that will take some period of time based on ndd settings. you do not necessarily want tcp to go belly-up if someone simply unplugs and reconnects a cable once and again, so even if there is a disconnect indication sent from the NIC, TCP (likely IP actually) would not necessarily say things were toast immediately. it might start tring to find another way to get the data there.
there is no rest for the wicked yet the virtuous have no pillows
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP