02-25-2005
Problem in HP-Unix while writing into socket
Our system is having a server and multiple clients. We are monitoring the client FDs using select() system call in HP-UX.
After establishing connection-using socket with the remote client, before start sending the data we are checking the status of socket using select( ) call. For first 16 clients the select() call is unblocked and FD_ISSET( ) returns success. But from the 17th client onwards, the select() is unblocked and FD_ISSET( ) is NOT RETURNING SUCCESS(it is returning negative value), both in HP-UX 11 and 11i. But the same logic works fine till 1024 clients in Solaris, AIX, Linux.
Source code is mentioned below,
Please tell how to rectify this problem.
fd_set Writefds;
struct timeval Timeout;
int RetCode;
int RetValue;
int SockDesc;
struct sockaddr_in client;
char BulkData[5000] = "Acknowledgement";
int retVal;
int clientlen = sizeof( struct sockaddr_in);
client.sin_family = AF_INET;
client.sin_addr.s_addr = INADDR_ANY;
client.sin_port = htons(SERVER_PORT);
SockDesc = socket(AF_INET, SOCK_STREAM, 0);
connect(SockDesc, &client,(socklen_t) clientlen);
Timeout.tv_sec = 0;
Timeout.tv_usec = 0;
FD_ZERO(&Writefds);
FD_SET(SockDesc, &Writefds);
RetCode = select(0, NULL, &Writefds, NULL, &Timeout);
if (RetCode > 0)
{
retVal = FD_ISSET(SockDesc, &Writefds);
if ( retVal > 0)
{
send(SockDesc, szBulkData,(size_t) sizeof(szBulkData), 0);
}
else
{
printf("FD_ISSET is failed:%d\n", retVal);
}
}
else if (RetCode == -1)
{
printf("select return Error:%d\n", errno);
}
else if (RetCode == 0)
{
printf("select return 0 [timeout occured].\n");
}
10 More Discussions You Might Find Interesting
1. Programming
Hi all,
I have developed server/client application (using C) and tested it on the same machine .. but when I deploy them on different machines I get connection timeout.
Well .. server machine and client machine exists on different network segments, so there is a linux firewall box to route... (3 Replies)
Discussion started by: Agent007
3 Replies
2. Programming
Can anyone help? I'm trying to write a program which will write to a socket. I can get the server to run, but always get an error when I try to connect.
It gives me an error at the "connect" command.
It's probably a simple error, but I can't seem to find it.
#include <sys/socket.h>... (6 Replies)
Discussion started by: Stevhp
6 Replies
3. Programming
hello,
when i execute my code server side it connects with the client and when i try to write through the server into the client the program exits. i could not understand whether it is the problem with the server or with the client.The Protocol is TCP/IP.
thanking you. (2 Replies)
Discussion started by: madfox
2 Replies
4. UNIX for Advanced & Expert Users
I am not able to receive the message on socket in the current process when its waiting for its child to exit.
code looks something like below
//in one thread of the current process
//thread 1
===============================================
int numBytes = read(sockid,buf,SIZE); //Now the... (2 Replies)
Discussion started by: swap007
2 Replies
5. Programming
Dear All,
I've searched many topics and googled many web-pages, but still I didn't found solution to this problem.
I want to set timeout for connect(). The thing is, that my code works only on BSD, on Linux (tested on SuSE box) it freezes at connect() call :(
bool
SomeFunc(std::string... (1 Reply)
Discussion started by: sggkxv
1 Replies
6. UNIX for Advanced & Expert Users
Hi,
I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime.
To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies
7. Programming
I wrote a program which will send a message to multiple clients(i.e, broadcasting) that are connected to a server.Once when the client receives a message from the server ,the client should read a file in the server and display it in the client.The client which responds (i.e, client wants all the... (3 Replies)
Discussion started by: vigneshinbox
3 Replies
8. Shell Programming and Scripting
Hello everyone:
I have a script that writes and read DATA in/from a socket, but i have a great problem while writing.
My socket is created in this way:
set connection
fconfigure $connection -encoding binary -translation binary -blocking 1
And the writer procedure is this one:
... (0 Replies)
Discussion started by: trutoman
0 Replies
9. IP Networking
Hi All
I have to design a server socket program.The requirement is Each connection from client will be in different threads.
The challenge is Suppose Server is now connected with two client Client A and client B.They will be in two different thread.
My application requirement is when... (4 Replies)
Discussion started by: mr_deb
4 Replies
10. IP Networking
Hi
My socket program is to communicate between the two systems connected with lan. Always i am getting an error saying bind value is -1 or not connected. ..If i run both the server and client programs in the same machine in two diff terminals they are working but they are not working between two... (3 Replies)
Discussion started by: Gurvareddy
3 Replies
LEARN ABOUT HPUX
showmount
showmount(1M) showmount(1M)
NAME
showmount - show all remote mounts
SYNOPSIS
[host]
DESCRIPTION
lists all clients that have remotely mounted a file system from host. This information is maintained by the server on host (see
mountd(1M)). The default value for host is the value returned by (see hostname(1)).
Options
Print all remote mounts in the format
where hostname is the name of the client, and directory is the root of the file system that has been mounted.
List directories that have been remotely mounted by clients.
Print the list of shared file systems.
WARNINGS
If a client crashes, executing on the server will show that the client still has a file system mounted. In other words, stale entries may
accumulate for clients that crash without sending an unmount request.
Also, if a client mounts the same remote directory twice, only one entry appears in Doing a of one of these directories removes the single
entry and no longer indicates that the remote directory is mounted.
FILES
remote mounted filesystem table
AUTHOR
was developed by Sun Microsystems, Inc.
SEE ALSO
hostname(1), mountd(1M), share(1M), share_nfs(1M), rmtab(4).
showmount(1M)