• 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

Blocking and non-blocking servers

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

What is blocking and non-blocking server in Java? How do you create it?

I have never used the java.nio package and documentation I found online was very confusing
I have previously only used java.net - ServerSocket and Socket to create communication between simple applications like a chat client etc. but never saw the necessity to use java.nio.
What is the plus point of using java.nio??


Thanks,
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jillika Iyer wrote:Hi,

What is blocking and non-blocking server in Java? How do you create it?

I have never used the java.nio package and documentation I found online was very confusion.
I have previously only used java.net - ServerSocket and Socket to create communication between simple applications like a chat client etc. but never saw the necessity to use java.nio.
What is the plus point of using java.nio??




A blocking read is ... well... you read the socket, and if there is data, you get it. And if there isn't data, then you wait for the data. A non-blocking read is ... you don't wait for the data if none is available. With non-blocking reads you can read from more than one socket at a time. For example, you open 10 network connections, and you can use the nio library to read from all ten at the same time.

Henry
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And notice that what Henry said didn't describe two ways for a server to work, it described two ways for a client to work. Perhaps your search for the term "blocking server", which isn't really a networking concept at all, is what is confusing you.
 
Jillika Iyer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I guess so. It was an interview question and I was stumped as I had never heard of that term before. I should have probably asked the interviewer the answer!!

Thank you guys!!
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jillika Iyer wrote:Yes I guess so. It was an interview question and I was stumped as I had never heard of that term before. I should have probably asked the interviewer the answer!!!



Yeah, asking for clarification would have been the way to go. And any decent interviewer will appreciate that you do so.
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic