Sign in to follow this  

Transport Endpoint Not Connected

This topic is 3462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to do a simple socket connection client/server in C and I get this every time I try to do a read. Client: -socket -connect -send Server: -socket -bind -listen -read There's got to be some important step I'm missing or something. Google was not very much help with this error.

Share this post


Link to post
Share on other sites
You're missing an accept(). A socket in a listening state is just waiting for connections you can't (I believe) read from it directly, you need to accept() a connection and then recv() from the socket it returns.

Share this post


Link to post
Share on other sites
The server had the accept thing in there and it returns a positive result.

For some reason, I just keep getting that error.

Might have something to do with the fact that after the write, the client just terminates - not sure if that's an issue.

Share this post


Link to post
Share on other sites
Quote:
Original post by gamechampionx
The server had the accept thing in there and it returns a positive result.

For some reason, I just keep getting that error.

Might have something to do with the fact that after the write, the client just terminates - not sure if that's an issue.
Possibly. Make sure you call shutdown() to make sure all the pending data is sent before closing the socket.

And is recv() returning -1 the first time you call it then? Or are you just checking WSAGetLastError() (Or errno) without checking what recv() returns?

Share this post


Link to post
Share on other sites
Shutdown didn't seem to do the trick.

It's failing on the first read. I'm actually using the read method for the time being and the result of something like (val = read(...)) > 0 is false.

The error message results from the perror("read").

Share this post


Link to post
Share on other sites

This topic is 3462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this