[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Recv: Transport Endpoint not connected

Posted on 2004-11-26
5
Medium Priority
?
2,196 Views
Last Modified: 2012-06-22
Hi,

I have a client-server program. The client issues a connect on a TCP socket and the server issues a bind, listen, then accept.

When I try to receive a message from the client after successfully acknowledging the hostname of the client that has connected, the recv returns the following error:

recv: Transport endpoint not connected.

Any ideas on how to fix?
0
Comment
Question by:jameswalt
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Mysidia
ID: 12683677
It sounds like you're trying to receive data before the connection is ready for that.

Are you using the select() or poll() system call in your event loop to wait until one
of the connections to your server is ready for read before you try to recv() the
information?

The typical order is..

1. Socket(),  Bind(),  Listen() for each port before the event loop

2. Select each port's fd for Read inside the event loop... when Read is YES, there is
    a connection waiting, issue Accept()
    Add connection to list

3. Select each accepted connection and wait for Read when you expect to possibly receive
    information (i.e. always) select for Write as long as the server still has information waiting
    to be written to the client with send()
    (Stop selecting for Write after all information is sent)

4.  Possibly select each client for Exception, though it might not always be clear what to do if a client's
     socket appears in the except set.

     On a user closed connection, typically you the socket gets selected for read, and the read() will return 0
     (Denoting EOF, end of connection)


Transport End Point not connected may also be showing up if the client was disconnected at an inoportune moment
for the server, like after it detected an attempted connection but before the accept() completed
(Accept can fail with transport end point not connected)
0
 

Author Comment

by:jameswalt
ID: 12683698
I am implementing thread-based - does this matter?
0
 
LVL 23

Accepted Solution

by:
Mysidia earned 200 total points
ID: 12683801
Certainly it matters, a thread based implementation is more complicated, at least
if you have multiple server threads that need to deal with I/O.

Each thread that does I/O needs to figure out when the connection or connections it is dealing with are ready
to receive or send information, and handle it correctly, and usually this means each thread is in some I/O loop for most of
its processing time (most real time will be spent waiting until the sockets are ready to recv() information that's been
sent to you or send() information you're waiting to get out).

What doesn't really change is the reason that you are getting the "transport end point not connected"
error.  

It still likely means that the process is attempting an operation on a socket that it's not ready for yet
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question