• Post Reply Bookmark Topic Watch Topic
  • New Topic

TCP Sockets and data streams  RSS feed

 
Matt Stimmel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a server-client pair that connect to each other through a TCP socket and they're supposed to be able to talk to each other....only they can't.

The server program simply stops and does nothing whenever the server attempts to read from the socket data stream. Here's the relevent code:



here's the relevent client code:




Notes:

*The server can send data to the client just fine.
*The server and client send data in the same way, but for some reason only the client can read.
* I am not 100% confident that the data is sending from the client...could that be the problem?
*I'm running the server and client on the same machiene. Shouldn't be a problem, should it?

Thanks.
 
Ben Zhou
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Matt:

I hope you already solved your problem.

I saw the problem came from here: you should put the server listening in a while loop, otherwise your server will start first, and it trys to listen, got nothing and exit.

Ben
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!