• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

A question on multiple tcp listeners for the same port?

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I am wondering if there is a way to establish multiple tcp listeners for the same port (eg 80)?The idea is trying to develop a server component which can response to the clients through the http port 80 in order to avoid firewall restriction. But it should co-exist with other installed servers (eg Apache, IIS, etc).
I searched on the internet, seems it is a mission impossible with java tcp sockets.
I know UDP can use the same port which is already occupied by another tcp lisenter. But it seems that there is a way to do that in tcp, since my boss is so sure that he emphasize it is http based communication component. I think that means there should be a reliable connection between the server and client. Or maybe I should use udp to implement a reliable connection for the communication?
Does anyone can give me some suggestions? Thanks a million!
Regards,
Joe
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't get more than one ServerSocket to listen on a single port: you will get a BindException every time. (see example below) I don't think this is possible in other languages either, though i could be wrong.
UDP is be nature and definition unreliable. there is no guarantee whatsoever that the information will reach its destination. Don't use UDP for anything critical.
HTTP is sent over TCP connections. You might want to google search for a tutorial on TCP vs UDP connection types, and then see how HTTP fits in to that scheme.
I can't help you much with the assignment because there are too many questions: what clients are you trying to respond to? if they are HTTP clients (like browsers), then why not give them over to the webservers directly? if they are some other type of client (telnet or ftp or something else entirely) then will they be able to use port 80? if the clients aren't using HTTP, what protocols will they be using? the program listening on port 80 will need to know what each protocol looks like and where to send it, which may prove very tricky indeed. those are some things to get you started thinking about what the program will need to deal with.

[ July 22, 2003: Message edited by: Jon Dornback ]
 
Joe J. Wang
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jon,
Thank you for the reply!
Yeah, your reply is same as my thought. I don't think there is a way for a java tcp socket(or some other part of java technology, except for udp) to listen to a port while another program started first is listening to it.
The idea of the assignement is to generate a communication component(javaBeans?) which can talk to the other components through port 80(in order to avoid the firewall restrication). Basicly, the communication is just the binary data exchange. It maybe used in a framework for groupware/collaboration.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not write your component as a Servlet, and thus explicitly have it work as a part of the web server on that host? If you can't beat 'em, join 'em.
 
Joe J. Wang
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,
Thanks for the reply! Yeah, u r right! The http tunneling(with servlet) can be the solution. But there is problem. The assignment require that the communication component should communicate with "clients/other components" only through tcp port# 80(it means both in and out goes through port80, since some firewall only allow data in/out through port 80). Then with http tunneling(servlet), how can it "send"(maybe I should call it "push') data to the clients/other components?
Thanks!!
Joe
 
Joe J. Wang
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does somebody can give me some hints for the porblem?
The http tunneling can only implement client pull in the situation that the communication component coexists with a web server. How can I do the server push? Thanks a lot!
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be talkin over my head here, so forgive me if this is dumb ... Is there any opportunity for a proxy? The proxy could listen on port n and echo everything back out to n+1, n+2 ... n+m. The other programs would have to be configured to listen to n+1 ... n+m.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!