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

Design for socket application

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am working on a web client which connects to a external server through a socket connection. Following are the two design approaches

Approach 1st:
Each request from a client opens a new socket connection to a server, sends request and process the response.

Problem: Too many socket connections

Approach 2nd:
There will be only one socket connection, all the client will send request through same connection.

Problem: Not sure how to map a response to a particular request, may be bit slower than approach first.

Approach 3rd:
Its more or same like 2nd approach, there will be only one socket connection between the client and external server, the only difference is for each client request a Runnable object will be created an submitted to the thread pool, which again are going to use the same connection for sending request.

Problem: how to map the response with the request?

Can somebody help me in finding the best way (Or if there is any other way of designing this). More over how can I solve the problem mentioned for 2nd and 3rd approach if I take either of it as a solution?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Duplicate thread. Locking.
 
    Bookmark Topic Watch Topic
  • New Topic