connect() system call fails while client tries to connect to a server givin duplicate name error.Can you please suggest me a way to remove this error?

Also I would like to know can we check if a socket is closed or not?

how to ensure that a socket is closed.


Please reply as soon as possible...

Recommended Answers

All 6 Replies

>>Can you please suggest me a way to remove this error?
Don't do that.

It seems the forum is not helpful any more.

anyways thanks for giving such replies.

All i needed to know was that does connect() function in C maintain a table from which it comes to know that the connection the client is going to request for is a duplicate connection(i.e, not unique 4-tuple) or is it the accept() function on the server side that does it?

Well the first response was because of your rubbish title.

And the second still applies because you've just described your problem in rather vague terms, rather than posting code to demonstrate the problem.

We're not generally interested in playing "guess the 1 of 1000+ ways you could have screwed up" based on your vague description, nor are we going to bust a gut providing you with a working example just because you wrote "urgent".

Read beej and try again.

I do know how to use the socket API's.
I dont want a code or something to solve my problem

when we call connect() it assigns a ephemeral port to the client if we dont hard code the client port and sends a SYN to the server.

But if the connection is just closed, the socket used for the connection goes into a TIME_WAIT state (refer Stevens for details).

Now if we try to connect to a port that is in TIME_WAIT state, connect fails with error EADDRINUSE.

All i wanted to know is how does the connect() socket API detect that the sockets are in TIME_WAIT state or not.

I gave it as urgent because of the lack of time in my hand.

I gave it as urgent because of the lack of time in my hand.

I can understand why you call it urgent, when it is urgent for you.
But that doesn't make it urgent for me.

I don't read every post on the boards I've signed up for,
I just check the first page, if there is anything I can help with.

So a subject saying "Urgent" is likely to get fewer responses that something like "connect() error in windows socket programming"

Are there some special reason you don't supply your sourcecode?
I do like to help people,
but I am not really inclined to write 100 lines of code for a specific post on some internet board.

Now regarding your problem:

What platform are you using?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.