java - Send and Receive packets from same TCP port -


i have 2 custom programs 1 sends stream of data , other 1 receive stream further processing. possible send data 1 tcp port , receive(read) data same port ?. if not can recommend alternative method.any appreciated. (the 2 programs run on same machine)

a tcp connection has 2 ends , permits communication in both directions. each end's sending port other end's receiving port. case.

if you're asking if each end's sending port can same other end's receiving port, answer yes. that's case.

if you're asking if both ends can have same sending , receiving port, answer is:

1) if source ip address same on both ends (say 127.0.0.1) absolutely not. if be, impossible distinguish between 2 endpoints.

2) if source ip address different on both sends (say 127.0.0.2 on 1 end , 127.0.0.3 on other) theoretically possible , can happen if you're using 2 different machines. far know, no common tcp/ip stack permits single port used in way if both ends on same machine. once you're listening on port, not permitted use port source port. , if you're using port source port, you're not permitted begin listening on it.

but feeling you're asking wrong question. if clarified you're trying , why, might answer different question of more you.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -