• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading from TCP socket problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am new with TCP socket's.
My problem is as follows:
I tried a sample program that listen as a server on desired port, read data from socket and send the data back (see code). But nothing happens. In network monitor I can see that the data from client are comming but nothing is sended back.
Can anybody help to understand where is my problem.

thanks

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code looks fine to me. What do you mean by "nothing happens"?
How about putting in additional System.out.println() messages, for example immediately before and after echoServer.accept() and after the while(true) loop. That will help you establish if the code is doing what you think it is doing.
One thing I notice is that this code will only handle one client. Ever. So if you hooked up once and didn't restart the server, your next client will not be serviced (though I'd expect the while(true) to exit with an exception when the first client exited. . .)
 
Michal Bury
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. I found the problem. It was on the Client side. It sended data without
"end of line", therefore I can not use readln() but only read.
 
reply
    Bookmark Topic Watch Topic
  • New Topic