0

How can you send a stringrequest to a specific ip address and port instead of a url using volley?

My code currently looks like this:

public void onURLPassed(final String urlOfWebsite) {

    Log.d(TAG, "Url passed: " + urlOfWebsite);

    String tag_json_obj = "json_obj_req";

    String serverURL = "http://test.me/api/request/page";

    StringRequest jsonObjReq = new StringRequest(Request.Method.POST,
            serverURL,
            new Response.Listener<String>() {

                @Override
                public void onResponse(String response) {
                    Log.d(TAG, response);
                    String parsedResponse = parse(response); 
                    if (parsedResponse.equals("Error: This is not a valid website")) { 
                        if (isViewAttached()) {
                            getView().displayMessage("This is not a valid website");
                        } else {
                            // error handling
                        }
                        return;
                    }
                    parsedResponse = parsedResponse.replace("\\" + "n", "  \n");
                    parsedResponse = parsedResponse.replace("\\" + "\"", "\"");
                    getView().displayWebsite(parsedResponse.substring(1, parsedResponse.length()-1));
                }
            }, new Response.ErrorListener() {

What I want to do now is send the same POST request to for example 12.123.12.123:40 instead of the serverURL http://test.me/api/request/page

How would I go about doing this?

Numb3rs
  • 45
  • 1
  • 8
  • Possible duplicate of [How to use volley library for network call using Socket(IP address) and port number(eg. 1234)?](http://stackoverflow.com/questions/39344438/how-to-use-volley-library-for-network-call-using-socketip-address-and-port-num) – Abhishek Jain Feb 12 '17 at 14:15
  • Found something, might be helpful for other people as well: [Really simple tcp client](http://stackoverflow.com/questions/38162775/really-simple-tcp-client) – Numb3rs Feb 12 '17 at 15:05

1 Answers1

1

Volley is an Http library. You can't make a call like this to an ip-address and a port using Volley. See this.

Abhishek Jain
  • 3,562
  • 2
  • 26
  • 44