I am trying to write code for a client-server scenario using AF_INET sockets..
As is usually the case, everything works fine and dandy on my machine, but gives me the following error at runtime:
send: Socket operation on non-socket
The error is thrown by the server when trying to send the next plan of action the the client. Note that this is neither the first nor the first receive between the client and servers..many previous exchanges were successful, and the failure occurs consistently at this point.
The below snippet is within a select while(1) loop accepting incoming connections from clients. no_of_clients is a fixed parameter giving max cllient count.
argv[3] is the hop count a packet is to bounce through the network.
clientfds[client_count] = new_client;
if(client_count == no_of_clients)
{
//FINAL--
printf("Sending command\n");
if(atoi(argv[3])==0)
{
printf("Trace of packet:\n");
for(i=1; i<=no_of_clients; i++)
{
len = send(clientfds, "Shutdown", 8, 0);
if (len != 8)
{
fprintf(stderr,"Send sent partial string!\n");
perror("send");
exit(1);
}
}
exit(0);
}
else
{
for(i=1; i<=no_of_clients; i++)
{
len = send(clientfds, "Charge!!", 8, 0);
if (len != 8)
{
fprintf(stderr,"Yes I Send sent partial string!\n");
perror("send");
exit(1);
}
}
}
//FINAL--
printf("Command sent..waiting for listener ready setup\n");
Relevant O/p portion..
...
Sending command
Yes I Send sent partial string!
send: Socket operation on non-socket
...
The only root cause common to this error from google(apart from semantic errors) was exceeding MTU size. The send() definitely is not exceeding any MTUs here as it is very small.
The code runs fine on a 64bit Ubuntu 11.04 install, but fails on a RHEL 5 64 bit machine
Any ideas guys?
---------- Post updated at 01:43 PM ---------- Previous update was at 04:24 AM ----------
Still haven't been able to resolve the issue.