How to find what pc in my network is with the port 8080 open so i can try to achieve its webservice

Sorry i asked wrong before but thats what i really need todo.
From my android device i need to search in the network and find my pc that is running the webservice by the 192.168.x.x:8080
So im thinking that founding the pc with the 8080 port open is the answer but how to do that?

Posts

  • HiltonMenezesHiltonMenezes BRMember ✭✭
    edited September 2013

    Thinking about using protopad maybe?

  • HiltonMenezesHiltonMenezes BRMember ✭✭

    https://code.google.com/p/boxeeremote/wiki/AndroidUDP

    This is java but i want the simplest code to get what ip is using that port

  • CheesebaronCheesebaron DKInsider, University mod

    What you want to do is to port scan all the IP's in the sub net your are on. Notice on some networks this is not allowed.

    Maybe you should think about it differently. Why not use Push Notifications to notify the phone about the IP of the server instead?

  • HiltonMenezesHiltonMenezes BRMember ✭✭

    I ll make this as clear as i can, i will have this android device that will be connected to a network that a pc with a webservice is... i already made the entire app between webservice and android with restsharp and stuff, but i need to type the serverip and the port everytime i want to connect and now i need to make my app find that webservice by itself...

    Im breaking my head for real for two days and finded nothing useful...
    How could i do this by push notifications?

  • CortezCortez USMember ✭✭✭

    The simpliest way to creating a settings layout. You have two settings: webservice's IP, webservice's Port. You can set this one time, and the application automatically try to connect to this endpoint.

    If the webservice address changes then you can reset your settings one more time, not everytime.

    If the connection is failed then the application ask the user to set the correct endpoint.

    As Cheesebaron suggested you should do the invers. The webservice's computer should publish information about the service, for example about his endpoint. You can do it with multicasting for example. You set a specified multicast address where the webservice's computer send periodically messages with your important information.

    At the start of your android application programmatically joins to this multicast address, get the information and try to connect to this endpoint.

  • HiltonMenezesHiltonMenezes BRMember ✭✭
    edited September 2013

    The problem is that in that case i would need to set stuff you know? My boss told me the app needs to find the server ip by itself you know without typing anything... all i need is to click on a button and somehow get the server IP... is impossible for me to send information to all pcs in the net and receive something only from the pc thats running the service and get its ip? Or something like that?

  • CheesebaronCheesebaron DKInsider, University mod

    Not impossible. As I suggested in one of your other threads about the same topic you can get the current active PC's by looking in the ARP table. However, if no one has accessed your web server for some time it might not appear on the list. Port scanning the network for PC's with port 8080 open is another possibility, however several servers might answer with a positive, hence you will need to ask all of the servers if they are the correct one.

    If you have no knowledge on how LAN and Internet works, I strongly suggest you read up on that.

  • HiltonMenezesHiltonMenezes BRMember ✭✭

    Im studying Cheesebaron srry being newbie, im using
    http://www.edumobile.org/android/android-development/socket-programming/
    I got the ideia for real i just cant translate to C# a little help please

  • CheesebaronCheesebaron DKInsider, University mod

    You said there was a web service running on 8080? What does this have to do with Socket programming?

  • CortezCortez USMember ✭✭✭

    With Ping you cannot detect the web server on which IP is it running any the less you know the port(8080). You can just filtering the possible computers. After that you can try to create TCP connection to detect are there any running tool on the 8080. You get a SocketException if not.

  • HiltonMenezesHiltonMenezes BRMember ✭✭

    So im now using

    System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient ();
                button.Click += delegate {
                    for (int i=1; i<=253; i++)
                    {
                        //int a = 1;
                        IAsyncResult iaResult = client.BeginConnect ("192.168.0." + i.ToString (), 8080, null, null);
                        iaResult.AsyncWaitHandle.WaitOne(200, false);
                        if (client.Connected)
                        {
            button.Text = "192.168.0."+i;
                     break;
                }    
          }
    }
    

    SO it was suposed to run through all the ips and if the 8080 port is open it would change the button text but sometimes i test and it works and stops on 16 like 10 tests in a row and then all of sudden is starts to find random ips in a row too like 30 70 121 etc...

    What can be happening? there's something wrong im doing?

  • HiltonMenezesHiltonMenezes BRMember ✭✭

    There isnt a way for me to send a broadcast signal in determined 192.168.x and then get what ip has the 8080 open?

  • FZelleFZelle DEMember ✭✭✭

    No.

    Stop wasting your time with trying, start getting the Basics by reading documentation about IP and networking.

Sign In or Register to comment.