Transport Endpoint Not Connected

Started by
3 comments, last by gamechampionx 15 years, 10 months ago
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.
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!
Advertisement
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.
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.
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!
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?
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").
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!

This topic is closed to new replies.

Advertisement