read/write to a 'foreign' socket

Heya

I wanted to ask if there is a possibility to read/write to a socket, that is used by another application (on the same computer). Basically I want to manipulate its datastream (drop/replace/react to specific packets). Could you help me getting started? Thanks in advance for any help.

Greetings

[317 byte] By [EarIa] at [2007-10-2 10:51:33]
# 1
What are you attempting to actually do and why? Because your explanations thus far sound devious.
GeneralYerevana at 2007-7-13 3:10:35 > top of Java-index,Archived Forums,Socket Programming...
# 2
I want to kind of 'infiltrate' the packetstream of an application (mIRC) in order to add some features I'd like to have.
EarIa at 2007-7-13 3:10:35 > top of Java-index,Archived Forums,Socket Programming...
# 3

> I want to kind of 'infiltrate' the packetstream of an

> application (mIRC) in order to add some features I'd

> like to have.

Reading the packets is one thing (and not a very Java thing either but let's just put that aside for now). But you want to manipulate them mid course? This doesn't seem like it will be possible or practical. You can't just make changes willy nilly to a stream of data. The other end is probably expecting a certain format etc and the changes you will make seem more than likely to disrupt that format.

I think you need a better and more realistic approach to solve your problem.

EarIa at 2007-7-13 3:10:35 > top of Java-index,Archived Forums,Socket Programming...
# 4

It's not like I don't know the data format of the application. I have enough knowledge when it comes to networking. It's also possible, because there are programs out there (packet sniffer) that can use an open socket and send packets using it. My problem is, that I have no idea how to implement the whole thing in Java.

EarIa at 2007-7-13 3:10:35 > top of Java-index,Archived Forums,Socket Programming...
# 5

First i don't know the way irc works. The solution i give is for grogram X that use tcp/ip(or udp) to connect to server Y on port Z.

So we create program P that listen on port Z on localhost and connect to port Z on host Y. Then we connect program X to program P on port Z on localhost. Program P listen the content that program X send and send them(with or without correction) to server Y. When server Y respond the program P sends the answer to program X. So for program X there is no matter that it's not connected directly to Y.

This dosen't work if it use ssl or something like it.

p_a_t_s_oa at 2007-7-13 3:10:35 > top of Java-index,Archived Forums,Socket Programming...
# 6
Yeah, I also thought of that local proxy thingie (= but I was unsure if this would work with Java and it would have been easier the other way. Well thanks for the hint, I'm gonna try it soon.
EarIa at 2007-7-13 3:10:35 > top of Java-index,Archived Forums,Socket Programming...