Operating System - HP-UX
1752794 Members
7007 Online
108789 Solutions
New Discussion

connect error in socket programming

 
pradeepraj
New Member

connect error in socket programming

Hi frns,

I have written a socket programming in C to interact with java. I do act as a client and java acts as a server & java is getting invoked from my C code.

When i connect it is a non blocking call and it returns -1(Connection refused). Could you please suggest some soln for this.

I would like to add one more thing... I need to recall my connect in client repetedly untill the server is up and do accept my connect.

Note: we tried sleep before the connect and while but ended up in vain.
1 REPLY 1
Steven Schweda
Honored Contributor

Re: connect error in socket programming

"Connection refused" normally means that
you've reached the other system, but that
there's no program listening at the port
you've specified.

Which port are you expecting to use?

Does "telnet server_host that_port" work, or
do you get "connection refused"?

What makes you believe that your server is
running and listening at the port you're
trying to use?

> I need to recall my connect in client
> repetedly untill the server is up and do
> accept my connect.

So, what's stopping you from doing that?
(Of course, you can burn a lot of CPU and
network resources by retrying this in a
wait-less loop. Also, if no one is listening
at the other end, retrying is not likely to
change much.)

> [...] but ended up in vain.

What does that mean? Symptom descriptions
like "It didn't work" are approximately
useless.