- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: socket receive program
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
Forums
Discussions
Discussions
Discussions
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
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
06-09-2015 01:11 AM
06-09-2015 01:11 AM
socket recive program
I wrote a program but i always run 4 hours and keep loop
program is still alive but the program do nothing,
does any one know how to solve this problem
below is gdb information and source code
int
CHpuxSocket::readn(int fd, char *buf, unsigned int len)
{
//printf("INFO: HpuxSocket::readn\n");
int cnt;
int rc;
cnt = len;
int counter = 0;
try
{
while (cnt > 0)
{
rc = recv(fd,buf,cnt,0);
//printf("rc=%d\n",rc);
if (rc < 0)
{
if (counter >= 3)
{
return -1;
}
if (errno == EAGAIN)
{
counter++;
continue;
}
else
return -1;
}
if (rc == 0)
return len-cnt;
buf += rc;
cnt -= rc;
}
return len;
}
catch (...)
{
printf("ERROR: Exception happen\n");
return len;
}
}
Attaching to program: /usr/local/sbin/ISAgent/isAgent, process 1766
0x60000000c040b3f0:0 in _recv_sys+0x30 () from /usr/lib/hpux32/libc.so.1
(gdb) bt
#0 0x60000000c040b3f0:0 in _recv_sys+0x30 () from /usr/lib/hpux32/libc.so.1
#1 0x60000000c0420dc0:0 in recv+0x80 () from /usr/lib/hpux32/libc.so.1
warning:
ERROR: Use the "objectdir" command to specify the search path for objectfile CHpuxSocket.o.
If NOT specified will behave as a non -g compiled binary.
#2 0x431c190:0 in CHpuxSocket::readn(int,char*,unsigned int)+0xc0 ()
#3 0x431b1f0:0 in CHpuxSocket::GetSessionKey(char*,char*)+0x5b0 ()
warning:
ERROR: Use the "objectdir" command to specify the search path for objectfile irmassock.o.
If NOT specified will behave as a non -g compiled binary.
#4 0x40b4410:0 in irmassock::bAuthenticate()+0x70 ()
warning:
ERROR: Use the "objectdir" command to specify the search path for objectfile irmas.o.
If NOT specified will behave as a non -g compiled binary.
#5 0x40a92c0:0 in irmas::bConnectToServer(char*,int)+0x180 ()
#6 0x409e3a0:0 in irmas::bConnectToServer(int)+0x40 ()
#7 0x40a03c0:0 in irmas::Routine(int)+0x110 ()
warning:
ERROR: Use the "objectdir" command to specify the search path for objectfile irmas_main.o.
If NOT specified will behave as a non -g compiled binary.
#8 0x409afb0:0 in main+0xa90 ()
(gdb)
- Tags:
- HP-UX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 10:08 AM
06-15-2015 10:08 AM
Re: socket receive program
>try/catch
This is useless if you are just calling libc routines. They don't throw C++ exceptions.
#1 0x60000000c0420dc0:0 in recv+0x80 /usr/lib/hpux32/libc.so.1
#2 0x431c190:0 in CHpuxSocket::readn(int,char*,unsigned int)+0xc0
The stacktrace just shows you waiting on a socket read.
(It also would help if you followed a consistent indentation policy.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2016 10:25 PM
03-22-2016 10:25 PM
Re: socket receive program
Sorry I donot know how to solve this problem with
my problem is hang with recv() os library
(gdb) where
#0 0x60000000c037d010:0 in _recv_sys+0x30 () from /usr/lib/hpux32/libc.so.1
#1 0x60000000c03909b0:0 in recv+0x170 () from /usr/lib/hpux32/libc.so.1
#2 0x43154c0:0 in CHpuxSocket::readn () at hpux/CHpuxSocket.cpp:271
#3 0x43147b0:0 in CHpuxSocket::GetSessionKey () at hpux/CHpuxSocket.cpp:357
#4 0x40b1490:0 in irmassock::bAuthenticate () at irmassock.cpp:223
#5 0x40a6630:0 in irmas::bConnectToServer () at irmas.cpp:424
#6 0x409c730:0 in irmas::bConnectToServer () at irmas.cpp:402
#7 0x409e590:0 in irmas::Routine () at irmas.cpp:1209
#8 0x40994f0:0 in main () at irmas_main.cpp:344
below is my source code ,how to solve it
int
CHpuxSocket::readn(int fd, char *buf, unsigned int len)
{
//printf("INFO: HpuxSocket::readn\n");
int cnt;
int rc;
cnt = len;
int counter = 0;
try
{
while (cnt > 0)
{
rc = recv(fd,buf,cnt,0);
//printf("rc=%d\n",rc);
if (rc < 0)
{
if (counter >= 3)
{
return -1;
}
if (errno == EAGAIN)
{
counter++;
continue;
}
else
return -1;
}
if (rc == 0)
return len-cnt;
buf += rc;
cnt -= rc;
}
return len;
}
catch (...)
{
printf("ERROR: Exception happen\n");
return len;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2016 12:48 AM
03-26-2016 12:48 AM
Re: socket receive program
>my problem is hang with recv(2)
This will hang unless you are in non-blocking mode.
(As I mentioned 9 months ago, remove the try/catch as useless on HP-UX.)