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
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 ]
use the [CODE] tags - it makes it much easier for people to help you.
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.
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
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!
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.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi