u mean sending something to client by server??!
if this what u mean u can use:
BufferedReader & PrintWriter and it will work
On Mar 18, 5:40 pm, eric m <[EMAIL PROTECTED]> wrote:
> John,
>
> I've tried everything I can think of togetthis working with no luck.
> As far as I can tell there is no way togetthe emulator to receive
> packets from an external source. I tried on windows XP and had a
> similar experience as you, so I migrated the whole thing to redhat and
> had no luck there either.
>
> I would love for someone to prove me wrong, but I don't know what else
> could be done besides digging into the emulator sourcecodeand
> figuring something out from there.
>
> Has anyone else had any success with sending UDP or TCP to the
> emulator?
>
> On Mar 18, 3:51 am, "John P." <[EMAIL PROTECTED]> wrote:
>
>
>
> > This thread has excellent info. Thanks!
>
> > I'm also trying to communicate between 2 emulators within one box. To
> > see ifmyenvironment works, I tried the following with m5-rc15 on
> > Windows XP:
>
> > 1) Copy Eric'scodeabove into two separate Activities.
> > 2) Start server on one emulator.
> > 3)telnetlocalhost5554 and "redir add udp:4444:4444". Console says
> > "OK".
> > 4) Start client on another emulator.
>
> > After Step 3, when I do "netstat -b" (Cygwin), I don't see a
> > connection for port 4444, only ports 5554, 5555, etc for the basic
> > emulator.
>
> > When I relaunch the UDP client, I see the Log.d("UDP", "***Packet sent
> > from server"). But the server prints Log.d("UDP", "***Waiting on
> > packet!") and never gets to Log.d("UDP", "***Packet received").
>
> > Additional info: at one time, Windows prompted to "keep on blocking"
> > or "unblock" emulator.exe from connecting to internet. I had clicked
> > on "keep on blocking" then. But I later went toControlPanel->Windows
> > Firewall and added emulator.exe as an exception. But I have
>
> > little faith in this Windows Firewallcontrolsetting because when I
> > removed GoogleTalk from the exception list, GoogleTalk still worked
> > fine (after restarting it). So I'm kinda worried thatmyinitial
> > "keep on blocking" permenantly blocked emulator.exe or something. So
> > I even added port 4444 separately. I even tried disabling the whole
> > firewall. Still, the server never logs that it receives the UDP, nor
> > do I see any netstat connection on port 4444.
>
> > Do you guys have any suggestions on what other tests I can run to see
> > what's wrong?
>
> > On Mar 14, 5:12 am, Digit <[EMAIL PROTECTED]> wrote:
>
> > > you're not saying exactly on which machines you're setting up things, so
> > > it's a bit ambiguous.
> > > here's something you could try though:
>
> > > machine A is your development machine, running one instance of the
> > > emulator
> > > (console on port 5554)
> > > machine B is your remote machine where your client is
>
> > > first check that you can properly tunnel from B to A. for example, try to
> > > setup a TCP tunnel from B:localhost:5554 to A:localhost:5554. then on B,
> > > try
> > > to "telnetlocalhost5554", this should connect you to the console of the
> > > emulator running on A. if this doesn't work, there is something wrong in
> > > your Putty setup, and fix this.
>
> > > when it works, use the console to add the UDP redirection on A (from
> > > A:localhost:4444 to emulator:localhost:4444), then use Putty to add a
> > > redirection from B:localhost:4444 to A:localhost:4444
>
> > > finally, start you client, it should work (in theory)
>
> > > On Fri, Mar 14, 2008 at 1:37 AM, eric m <[EMAIL PROTECTED]> wrote:
>
> > > > Has anyone got something like this successfully working? If so can I
> > > >getdetails on how you forward packets sent to the computer android is
> > > > running on (for example 192.168.1.111 : 4444) to port 4444 within
> > > > Android?
>
> > > > I have done the following things:
> > > > - connected to the running android emulator console and used:
> > > > redir add udp:4444:4444
>
> > > > - i have Putty configured as follows:
> > > > local ports accept connections from other hosts (checked)
> > > > port 4444 is forwarded to 127.0.0.1:4444
> > > > I also tried forwarding 4444 tolocalhost:4444
>
> > > > No luck either way. Netstat is showing the incoming UDP packets as
> > > > being "discarded due to invalid port".
>
> > > > Please help!
>
> > > > On Mar 13, 11:43 am, Digit <[EMAIL PROTECTED]> wrote:
> > > > > that's the idea, the emulator redirection would still be needed to
> > > > > allow
> > > > the
> > > > > server on the emulated system to receive the client's connection.
>
> > > > > On Thu, Mar 13, 2008 at 3:26 PM, eric m <[EMAIL PROTECTED]> wrote:
>
> > > > > > So I would forward the address/port of the machine - say
> > > > > > 192.168.1.111:4444 to 127.0.0.1:4444?
>
> > > > > > On Mar 13, 1:59 am, Digit <[EMAIL PROTECTED]> wrote:
> > > > > > > by design, the emulator's redirectioncodeonly listens on the
> > > > loopback
> > > > > > > interface (i.e. 127.0.0.1) so it will notgetpackets addressed to
> > > > your
> > > > > > real
> > > > > > > network interface(s) from an outside machine.
>
> > > > > > > you can do what youwantby using port forwarding, using a program
> > > > like
> > > > > > ssh
> > > > > > > or putty.
>
> > > > > > > On Thu, Mar 13, 2008 at 12:22 AM, eric m <[EMAIL PROTECTED]>
> > > > > > > wrote:
>
> > > > > > > > I have a UDP Listening server that works within the emulator. I
> > > > posted
> > > > > > > > thecodebelow for reference (More people should adopt this!) I
> > > > also
> > > > > > > > have a UDP client that works within the emulator (Again,codeis
> > > > > > > > below). I can send packets from the client to the server within
> > > > > > > > android and view the output in the log.
>
> > > > > > > > I also have a homemade UDP packet generator written in C++ (This
> > > > > > > > program works fine and generates proper packets, verified
> > > > > > > > outside
> > > > of
> > > > > > > > Android). It is running on a different computer overmyLAN. I
> > > >wantto
> > > > > > > > be able to send packets from that program into Android. The only
> > > > thing
> > > > > > > > I have found so far is to use the redir command:
>
> > > > > > > > While the emulator is running, I open a command line, dotelnet
> > > > > > > >localhost5554 (port of emulator - 1), and then use: "redir add
> > > > udp:
> > > > > > > > 4444:4444". This apparently forwards packets frommycomputer into
> > > > the
> > > > > > > > Android environment. I know this command works because a
> > > > > > > > seperate
> > > > > > > > program (Netstat) is showing "Emulator" listening on port 4444.
> > > > Great!
>
> > > > > > > > Just one problem - Android never receives the UDP packet sent
> > > > > > > > from
> > > > the
> > > > > > > > outside world, even though it is arriving at the computer. How
> > > > > > > > can
> > > > I
> > > > > > > > fix this?
>
> > > > > > > > SERVER::::::::::::::::::::::
> > > > > > > > importjava.net.DatagramPacket;
> > > > > > > > importjava.net.DatagramSocket;
> > > > > > > > importjava.net.InetAddress;
> > > > > > > > import android.util.Log;
>
> > > > > > > > //implements Runnable so it can be created as a new thread
> > > > > > > > public class UDPListener implements Runnable {
> > > > > > > > public static final String SERVERIP = "127.0.0.1";
> > > > > > > > public static final int SERVERPORT = 4444;
>
> > > > > > > > public void run() {
> > > > > > > > try { //mandatory error catching on Inet functions
>
> > > > > > > > //getserverAddress
> > > > > > > > InetAddress serverAddr = InetAddress.getByName(SERVERIP);
>
> > > > > > > > //Create the socket using the serverAddress
> > > > > > > > Log.d("UDP", "***Creating server");
> > > > > > > > DatagramSocket socket = new DatagramSocket(SERVERPORT,
> > > > serverAddr);
>
> > > > > > > > //create a buffer to copy packet contents into
> > > > > > > > byte[] buf = new byte[200];
>
> > > > > > > > //create a packet to receive
> > > > > > > > DatagramPacket packet = new DatagramPacket(buf, buf.length);
>
> > > > > > > > Log.d("UDP", "***Waiting on packet!");
>
> > > > > > > > //wait to receive the packet
> > > > > > > > socket.receive(packet);
> > > > > > > > Log.d("UDP", "***Packet received");
> > > > > > > > Log.d("UDP", "***" + new String(packet.getData()));
>
> > > > > > > > }
> > > > > > > > catch (Exception e) {
> > > > > > > > Log.e("UDP", "***UDP Server creation Failed!");
> > > > > > > > }
> > > > > > > > }
> > > > > > > > }
>
> > > > > > > > CLIENT::::::::::::::::::::::::::::
>
> > > > > > > > importjava.net.DatagramPacket;
> > > > > > > > importjava.net.DatagramSocket;
> > > > > > > > importjava.net.InetAddress;
> > > > > > > > import android.util.Log;
>
> > > > > > > > public class UDPTestPacket implements Runnable {
> > > > > > > > public static final String SERVERIP = "127.0.0.1";
> > > > > > > > public static final int SERVERPORT = 4444;
>
> > > > > > > > public void run() {
> > > > > > > > try {
> > > > > > > > InetAddress serverAddr = InetAddress.getByName(SERVERIP);
>
> > > > > > > > DatagramSocket socket = new DatagramSocket();
>
> > > > > > > > byte[] buf = "whatsup beetches".getBytes();
>
> > > > > > > > DatagramPacket packet = new DatagramPacket(buf, buf.length,
> > > > > > > > serverAddr, SERVERPORT);
> > > > > > > > socket.send(packet);
> > > > > > > > Log.d("UDP", "***Packet sent from server");
> > > > > > > > }
> > > > > > > > catch (Exception e) {
> > > > > > > > Log.d("UDP", "***Fail");
> > > > > > > > }
> > > > > > > > }
> > > > > > > > }- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---