File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes socket programming on 2 ports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket programming on 2 ports" Watch "socket programming on 2 ports" New topic

socket programming on 2 ports

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
How do I program a client application where the server communicates on 2 ports: it listens on 1 port and sends messages on another port.
It is urgent
Mallick Srinivas Choppa

Joined: Jan 20, 2003
Posts: 3
When you want to receive data on one socket and send data on the defferent socket then i would say let your client and server have both client socket and server sockets .
Client application will have server socket and client socket capability.
Server application will have server socket and client socket capability.
I mean like open a server socket on server and listen for client. once the client makes a connection to server send information of the client(like its the host Ip and port where it listening ) and now server will use this information(ip and port of the client) and connects to the client. so this way one socket can used for sending and another can be used for receiving.(This type connection is used by CuteFTP if i am not wrong).
This is best way what i can thing of, as we also used such type of communication.
hope this helps
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
i,am trying to do what have a suggested but in vain . PLease have a look

I agree. Here's the link:
subject: socket programming on 2 ports
It's not a secret anymore!