- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: recv error: Function is not available 0 251
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО07-16-2007 05:13 AM
тАО07-16-2007 05:13 AM
recv error: Function is not available 0 251
I have a query
i have written one small program .it will send and recv data continously.
My problem is:-
1.if i run this same program in linux .its working fine but if i run in HP-UX11iv1(PARISC) machine .i am getting following error
"recv error: Function is not available 0 251"
can u tell me .is it server regarding issue ?
how to fix this one?
Thanks in advance
Regards,
Moorthy
- Tags:
- recv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2007 05:19 AM
тАО07-16-2007 05:19 AM
Re: recv error: Function is not available 0 251
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2007 05:54 PM
тАО07-16-2007 05:54 PM
Re: recv error: Function is not available 0 251
can u tell me is there any mistake
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
fd_set rd_set;
fd_set wr_set;
fd_set er_set;
int maxFds = 16;
using namespace std;
#define PKT_LEN 1124
#define PORT_NUM 1707
int main ()
{
int nSocket, sockFd;
unsigned char *pktBuf = new unsigned char[PKT_LEN];
struct sockaddr_in serv, cli;
struct sockaddr fromAddr;
int fromLen = sizeof (fromAddr);
int clilen = sizeof (cli);
int bytesReceived;
int pktsRecvd = 1;
int pktsSent = 1;
int selRet;
// struct protoent *ptent;
//
// ptent = getprotobyname ("TCP");
// printf ("TCP PROTOCOL No. %d - %s\n", ptent->p_proto, ptent->p_name);
if ( (nSocket = socket(AF_INET, SOCK_STREAM, 6)) < 0) {
perror ("socket error");
return -1;
}
cout << "Socket# " << nSocket << endl;
memset(&serv, 0, sizeof(serv));
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = htonl(INADDR_ANY);
serv.sin_port = htons(PORT_NUM);
if (bind(nSocket, (struct sockaddr *)&serv, sizeof(serv)) < 0) {
perror ("bind error");
return -1;
}
if (listen(nSocket, SOMAXCONN) < 0) {
perror ("listen error");
return -1;
}
//clilen = sizeof(cli);
if ((sockFd = accept(nSocket, (struct sockaddr *)&cli,(socklen_t *)&clilen )) < 0) {
perror ("accept error");
return -1;
}
FD_ZERO (&rd_set);
FD_ZERO (&wr_set);
FD_ZERO (&er_set);
FD_SET (sockFd, &rd_set);
// FD_SET (sockFd, &wr_set);
// FD_SET (sockFd, &er_set);
while (1)
{
// if ((bytesReceived = recvfrom (sockFd, pktBuf, 1024,
// 0, &fromAddr, &fromLen)) <= 0)
if ((selRet = select (maxFds, &rd_set, &wr_set, &er_set, NULL)) < 0)
{
perror ("select error");
return -1;
}
cout << "Select returned - " << selRet << endl;
cout << "Checking if Error is set...";
if (FD_ISSET (sockFd, &er_set))
{
perror ("socket error");
return -1;
}
cout << " No error\n";
cout << "Checking if Read is set...";
if (FD_ISSET (sockFd, &rd_set))
{
cout << " Reading\n";
if ((bytesReceived = recv (sockFd, pktBuf, PKT_LEN, 0)) <= 0)
{
perror ("recv error");
cout << bytesReceived << " " << errno << endl;
return -1;
}
cout << bytesReceived << " Bytes reveived\n";
cout << "recvd pkt no. - " << pktsRecvd++ << endl;
FD_CLR (sockFd, &rd_set);
FD_SET (sockFd, &wr_set);
}
cout << "Checking if Write is set...";
if (FD_ISSET (sockFd, &wr_set))
{
fromLen = sizeof (fromAddr);
cout << " Writing\n";
if (send (sockFd, (const void *)pktBuf, bytesReceived, 0) != bytesReceived)
{
perror ("send error");
return -1;
}
cout << "sent pkt no. - " << pktsSent++ << endl;
FD_CLR (sockFd, &wr_set);
FD_SET (sockFd, &rd_set);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2007 07:59 PM
тАО07-16-2007 07:59 PM
Re: recv error: Function is not available 0 251
perror ("recv error");
cout << bytesReceived << " " << errno << endl;
Your error checking on this code is bad. If recv returns 0, you must not call perror nor print errno.
recv(2) says it returns 0 for:
The socket is blocking and the transport connection to the
remote node failed, or the remote side of a connection-based
socket has performed an orderly shutdown and there is no
more data to read (the socket has reached the end of its
data stream). Sockets with the O_NDELAY flag set may also
return 0 at any time when there is no data available.
- Tags:
- errno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2007 09:19 PM
тАО07-16-2007 09:19 PM
Re: recv error: Function is not available 0 251
i will check it and come back to u
Regards
moorthy.p